Untitled
unknown
html
2 years ago
19 kB
8
Indexable
<script>
$(document).ready(function() {
var videoInterval = 10;
var videoStatus = {};
function gtmEventCall(e, c, a, l, v, i, s) {
dataLayer.push({
event: e,
//category: c,
//action: a,
video_name: l,
video_elapsed_time: v,
video_link: i,
videoSource: s,
});
}
function getTitles(videoSrc, videoLoc) {
if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/635983894/rendition/1080p/file.mp4?loc=external&signature=9652911bd6ce7ad4ac7f48720f5ef59d9d94b4969e49b735b246314e822d659b"
&& videoLoc == "/myelofibrosis-mf")
return "performs spleen assessment at baseline and consistently throughout management as part of his patient care";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/635983894/rendition/1080p/file.mp4?loc=external&signature=9652911bd6ce7ad4ac7f48720f5ef59d9d94b4969e49b735b246314e822d659b"
&& videoLoc == "/myelofibrosis-mf/spleen-assessment")
return "on how spleen assessment is a marker of disease progression in patients with myelofibrosis and see his technique for assessment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/635983894/rendition/1080p/file.mp4?loc=external&signature=9652911bd6ce7ad4ac7f48720f5ef59d9d94b4969e49b735b246314e822d659b"
&& videoLoc == "/myelofibrosis-mf/resources")
return "proactive spleen assessment in patients with myelofibrosis";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/659335151/rendition/1080p/file.mp4?loc=external&signature=a0840a4eb37fc80dac0fcc56c54e1fd3ac25db00c9ffa5843bd9bcb61dc29433"
&& videoLoc == "/polycythemia-vera-pv")
return "characteristics that indicate advanced polycythemia vera (pv)";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/659335151/rendition/1080p/file.mp4?loc=external&signature=a0840a4eb37fc80dac0fcc56c54e1fd3ac25db00c9ffa5843bd9bcb61dc29433"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "identifying patients with advanced pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/662520193/rendition/1080p/file.mp4?loc=external&signature=8efe6d9fb1ae9ae020111711fe90bead6901183971091b855c8c3888ad23f26b"
&& videoLoc == "/polycythemia-vera-pv/symptoms")
return "30 nights spent sweating since dave's last pv appointment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/680290801/rendition/1080p?loc=external&signature=fdbb568d69cbe71bb0bff55e9605f95a3ba44c765c58078030b6bd51722a1b9f"
&& videoLoc == "/polycythemia-vera-pv/symptoms")
return "36 days of itching since julie's last pv appointment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120868/rendition/1080p/file.mp4?loc=external&signature=27a0637a03047549183fed5ff59f4ca9aef51480fd4a52865eb6fc7cdb438773"
&& videoLoc == "/polycythemia-vera-pv/symptoms")
return "40 days lost to fatigue since nick's last pv appointment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/659338062/rendition/1080p/file.mp4?loc=external&signature=91235a6f79485f5ffa77137b624bb5361af319aca258ad989bd57793e5c23e73"
&& videoLoc == "/polycythemia-vera-pv/symptoms")
return "about the importance of looking beyond blood counts and actively monitoring pv symptoms";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/659339141/rendition/1080p/file.mp4?loc=external&signature=0a20f2e5beb8d2460a9ae1ddd85ada13361eddd5a2fe6d6648b34b03fe83cc72"
&& videoLoc == "/polycythemia-vera-pv/symptoms")
return "investigating the causes of increased symptom burden in patient with pv, including looking at blood counts and current treatment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120352/rendition/1080p/file.mp4?loc=external&signature=459ede07f2117f519d3838a134dc7067851d744bdd41016fed6244f69df6dae1"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "managing white blood cell counts in patients with pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/771450901/rendition/1080p/file.mp4?loc=external&signature=f3e403d7c64339174600500eecc18a0020818ac1006acaecf57229a33159869f"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "symptoms of pv: identification and classification";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/656960026/rendition/1080p/file.mp4?loc=external&signature=8cbfad2c756d09e88d3db6274f58bb70d4cdc9695ba462d02d24ca919060c6aa"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "why we need to assess symptoms in our patients";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120997/rendition/1080p/file.mp4?loc=external&signature=65691e71db44ca80bcdefcf84bdec526c72c5639d88fe03569971c276a6fadcf"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "hematocrit control <45% and risk of thrombosis in patients with pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120713/rendition/1080p/file.mp4?loc=external&signature=3a9787b74451d7f9da595598ddc2e2bed65f78b47ee2becefb1f0c50bfdac0e6"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "what is our role in improving patients care in pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120595/rendition/1080p/file.mp4?loc=external&signature=3543bd5c921cb35f0b3568fba114ab7b0c5297f62706991cf09118bec331fd19"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "assessing and managing disease related symptoms in patients with pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/656958128/rendition/1080p/file.mp4?loc=external&signature=ef16dba9cf3a7e86dbf2a1c01aef0ee4b62933df1ae70a6192263e4775a00413"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "why blood counts may be a sign that it is time for a change in clinical management";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/662520193/rendition/1080p/file.mp4?loc=external&signature=8efe6d9fb1ae9ae020111711fe90bead6901183971091b855c8c3888ad23f26b"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "30 days spent sweating since dave's last pv appointment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/664120868/rendition/1080p/file.mp4?loc=external&signature=27a0637a03047549183fed5ff59f4ca9aef51480fd4a52865eb6fc7cdb438773"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "40 days lost to fatigue since nick's last pv appointment";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/659336590/rendition/1080p/file.mp4?loc=external&signature=ccb44e7698620f2695d3573df852bf70ee93c14a5e2fe8f68209d4b66650a20a"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "elevated hematocrit and thrombotic risk";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/639036140/rendition/1080p/file.mp4?loc=external&signature=55bfee84e2bdd0305cf6acf19c486009772fe929c00ff58c6db7363296e7fd72"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "what contributes to thrombotic risk in pv";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/771450996/rendition/1080p/file.mp4?loc=external&signature=787bbab484a3fc1f3f5f2117a9395cf70f5a131a9fa1c9f5637d93cb76f3a704"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "progressive symptoms in pv: monitoring for signs of advanced disease";
else if (videoSrc == "https://player.vimeo.com/progressive_redirect/playback/680290801/rendition/1080p?loc=external&signature=fdbb568d69cbe71bb0bff55e9605f95a3ba44c765c58078030b6bd51722a1b9f"
&& videoLoc == "/polycythemia-vera-pv/resources")
return "36 days of itching since julies last pv";
else
return "Failed to get video title";
}
function analyticsTimeUpdate(videoId, event) {
var currentVideo = document.getElementById(videoId);
var videoData = videoStatus[videoId];
titleTemp = jQuery(event).attr("poster");
videoSrc = jQuery(event).find('source').attr("src");
videoLoc = window.location.pathname;
mainTitle = getTitles(videoSrc, videoLoc);
videoData.current = Math.round(currentVideo.currentTime);
var pct = Math.floor(100 * videoData.current / currentVideo.duration);
for (var marker in videoData._progressMarkers) {
if (pct >= marker && marker > videoData.greatestWatchedPosition) {
videoData.greatestWatchedPosition = marker;
}
}
if (videoData.current >= 60 && !videoData.watched60 ) {
eventName = "video_progression_30s";
categoryVal = "Video";
actionVal = "video_progression_30s";
videoName = mainTitle;
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = "30";
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
videoData.watched60 = true
}
if (videoData.current >= 30 && !videoData.watched30 ) {
eventName = "video_progression_60s";
categoryVal = "Video";
actionVal = "video_progression_60s";
videoName = mainTitle;
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = "60";
videoData.watched30 = true
}
if (pct >= 25 && !videoData._progressMarkers[25]) {
eventName = "video_progression_25%";
categoryVal = "Video Milestones";
actionVal = "video_progression_25%";
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = Math.round(currentVideo.duration) * (25 / 100);
videoName = mainTitle;
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
videoData._progressMarkers[25] = true;
}
if (pct >= 50 && !videoData._progressMarkers[50]) {
eventName = "video_progression_50%";
categoryVal = "Video Milestones";
actionVal = "video_progression_50%";
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = Math.round(currentVideo.duration) * (50 / 100);
videoName = mainTitle;
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
videoData._progressMarkers[50] = true;
}
if (pct >= 75 && !videoData._progressMarkers[75]) {
eventName = "video_progression_75%";
categoryVal = "Video Milestones";
actionVal = "video_progression_75%";
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = Math.round(currentVideo.duration) * (75 / 100);
videoName = mainTitle;
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
videoData._progressMarkers[75] = true;
}
}
function analyticsPlay(videoId, event) {
var currentVideo = document.getElementById(videoId);
var videoData = videoStatus[videoId];
videoData.current = Math.round(currentVideo.currentTime);
titleTemp = jQuery(event).attr("poster");
videoSrc = jQuery(event).find('source').attr("src");
videoLoc = window.location.pathname;
videoTitle = getTitles(videoSrc, videoLoc);
if (videoData.current >= 0 && videoData.current <= 2) {
var ct = document.getElementsByTagName("video").currentTime;
eventName = "video_begins";
categoryVal = "Video";
actionVal = "video_begins";
videoName = mainTitle;
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = "1";
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
}
}
function analyticspause(videoId, event) {
var currentVideo = document.getElementById(videoId);
var videoData = videoStatus[videoId];
videoData.current = Math.round(currentVideo.currentTime);
var pct = Math.floor(100 * videoData.current / currentVideo.duration);
if (pct > 1 && pct <= 99) {
var titleTemp = jQuery(event).attr("poster");
var videoSrc = jQuery(event).find('source').attr("src");
var videoLoc = window.location.pathname;
var mainTitle = getTitles(videoSrc, videoLoc);
video_elapsed = Math.round(currentVideo.currentTime);
eventName = "video_paused";
categoryVal = "Video";
actionVal = "video_paused";
videoName = mainTitle;
videoLink1 = videoSrc;
videoSource = "vimeo";
videoElapsedTime1 = video_elapsed;
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
}
}
function analyticsEnd(videoId, event) {
var currentVideo = document.getElementById(videoId);
var videoData = videoStatus[videoId];
videoData.current = Math.round(currentVideo.currentTime);
var pct = Math.floor(100 * videoData.current / currentVideo.duration);
titleTemp = jQuery(event).attr("poster");
videoSrc = jQuery(event).find('source').attr("src");
videoLoc = window.location.pathname;
mainTitle = getTitles(videoSrc, videoLoc);
eventName = "video_ends";
categoryVal = "Video";
actionVal = "video_ends";
videoName = mainTitle;
videoLink1 = videoSrc;
videoElapsedTime1 = video_elapsed;
videoSource = "vimeo";
paused_status = false;
console.log({
'video ID': videoId,
'event Name': eventName,
'cat': categoryVal,
'action': actionVal,
'video name': videoName,
'video elapsed': videoElapsedTime1,
'video link': videoLink1,
'video source': videoSource
})
}
function eventHandler(e) {
var videoId = $(this).attr('id');
switch (e.type) {
case 'timeupdate':
handleTimeUpdate(videoId, e);
break;
case 'play':
analyticsPlay(videoId, e);
break;
case 'pause':
analyticspause(videoId, e);
break;
case 'ended':
analyticsEnd(videoId, e)
break;
default:
break;
}
}
$('video').each(function() {
var videoTagId = $(this).attr('id');
if (!videoTagId) {
videoTagId = 'gtm_video_' + Math.random().toString(36).slice(2);
$(this).attr('id', videoTagId);
}
videoStatus[videoTagId] = {
greatestWatchedPosition: 0,
_progressMarkers: {},
watched30: false,
watched60: false
};
for (var marker = 0; marker < 100; marker += videoInterval) {
videoStatus[videoTagId]._progressMarkers[marker] = false;
}
videoStatus[videoTagId].current = 0;
$(this).on("play pause ended timeupdate", eventHandler);
});
});
</script>Editor is loading...
Leave a Comment