Google Tag Manager 101 Part 9 - Youtube Tracking
28/11/2017
Google Tag Manager continues to improve and it has recently added some new functionality which is very useful indeed.
In the past it wasn't possible to record views of Youtube videos embedded into your website. It led to workarounds such as embededding the video into a lightbox so that tracking could be added to the click to open the lightbox - but that method couldn't tell you whether the video had been viewed or how far the viewer had reached in the video.
Recently a new release to Google Tag Manager enabled full tracking of Youtube videos including recording of starting and completing as well as percentage reached in between. While Youtube provides comprehensive statistics on your video across all the places it is posted (native Youtube, Facebook etc) , it is useful to know how well the video is performing for visitors to your website.
If one of your campaign goals is a video view, now you can configure that goal and measure it. The GTM Youtube trigger is flexible enough for you to record exactly which part of the video was reached. This can be useful if you know that viewers are likely to stop watching when the video content ends and miss the final few seconds of brand messages. In this case you can set your goal to be a percentage view that matches when the content ends.
This is a very fast way to enable a GTM trigger and tag for your website.
1. Add the built-in Video variables to your Google Tag Manager configuration. There are 8 in all.
2. Add this custom javascript as a User-Defined variable. This was borrowed from Simo Ahava's excellent article here
function() {
var status = {{Video Status}};
switch (status) {
case 'start':
return 'Start playing';
case 'pause':
return 'Pause';
case 'buffering':
return 'Buffering';
case 'progress':
return 'Reached ' + {{Video Percent}} + '%';
case 'complete':
return 'Reached the end';
}
}
This makes it easy to capture all video activity in a single tag and make it easily readable.
3. Create the trigger to look something like this. It is important to tick the "Add JavaScript API support to all YouTube videos" option. For Progress, you can either set the Percentages to trigger on or the actualy Time Thresholds. Use Percentages if you want a common trigger and tag for all videos.
4. Finally, create your Tag. The Action below should point to the Custom Javascript that you created in Step 2. The Label concatenates the Video Title and Video URL into a single field. If you display the same video on multiple pages, then adding {{Page Path}} to the Label will enable you to see which page the video action refers to.
And that is all you need to start tracking your videos. Look out for Scroll Tracking next ....
I am @nickbakernz for any comments.
Written by Nick Baker