Skip to content

Instantly share code, notes, and snippets.

@jramsahai
Last active June 23, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jramsahai/21f30d4cb4c84d4ed70f to your computer and use it in GitHub Desktop.
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/
<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>
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