Last active
June 23, 2016 03:48
-
-
Save jramsahai/21f30d4cb4c84d4ed70f to your computer and use it in GitHub Desktop.
We've worked with the Cardinal Path team quite a bit on projects using the Progress Events framework. I was asked to build out a setup into Google Tag Manager based off the instructions found here: http://www.cardinalpath.com/youtube-video-tracking-with-google-tag-manager-v2-and-universal-analytics-a-step-by-step-guide/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript' src="//play.vidyard.com/v0/api.js"></script> | |
<script type='text/javascript' src="//play.vidyard.com/v1/progress-events.js"></script> | |
<script type='text/javascript'> | |
VidyardProgressEvents(function (result){ | |
if (result.event==1) { | |
dataLayer.push({ | |
event: 'vidyard', | |
eventCategory: 'video', | |
eventAction: "Play", | |
eventLabel: result.player.metadata.chapters_attributes[result.chapter].video_attributes.name | |
}); | |
} else { | |
dataLayer.push({ | |
event: 'vidyard', | |
eventCategory: 'video', | |
eventAction: "Watched " + result.event + "%", | |
eventLabel: result.player.metadata.chapters_attributes[result.chapter].video_attributes.name | |
}); | |
} | |
}, [1,25,50,75,95]); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function () { | |
var patt = /play.vidyard.com/g; | |
for (var e = document.getElementsByTagName('script'), x = e.length; x--;) | |
if (patt.test(e[x].src)){ | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment