If you use YouTube as a video-hosting site, you can use Higher Logic's Web Tracking to record each instance of a visitor watching one of your embedded videos on your Higher Logic Thrive Marketing Professional (Thrive Marketing Professional) site.
NOTE: To do this, you must be authorized to make changes to your Thrive Marketing Professional site.
Track plays of your YouTube videos
Many YouTube videos are embedded using iFrames, so you'll have to retrieve YouTube's iFrame API.
TIP: Text files of the required script and code files are included at the end of this article.
To track plays of embedded YouTube videos:
- Add the Higher Logic Web Tracking Code to the bottom of your site page that hosts the embedded video.
- At the top of that page, include the API script that is shown below.
<script src="https://www.youtube.com/iframe_api"></script>
- Add the following iFrame code where you would typically add iFrame code.
<div id="vidWrapper">
<!-- The <iframe> (and video player) will replace this <div> tag. -->
<div id="ytplayer"></div>
</div>
Now you have to include code to receive the Play action from YouTube. This way, when someone plays a video on your site (by clicking the Play button), it will be recorded in your Web Tracking results.
- Add the following play-script code. Be sure to specify the correct video ID in the videoId: line.
<script>
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('ytplayer', {
height: '315',
width: '560',
videoId: 'f2iET4Phh4s', // change this to the correct video id
events: {
'onStateChange': function(event) {
if (event.data == YT.PlayerState.PLAYING) {
informz_trk('trackStructEvent',
'Change to something else',
'Clicked Play on Video',
'' // Value (Optional)
);
}
}
}
});
}
</script>
Now, you'll see interaction data related to video plays in your Web Tracking Report.
Code files
Below are .TXT files of the code used in this article. You can download these and save them for future use.