YouTube video tracking in Google Analytics with GTM

YouTube tracking in GTM

Google Tag Manager just added a new trigger for YouTube video tracking. This is a super simple, 3 steps and you can start tracking the performance of your YouTube videos in Google Analytics. Stéphane Hamel from CardinalPath provided a javascript that enabled us to do this more than 2 years ago. Now, that Google added in the GTM a built-in trigger, you don’t need to write even one row of code.

This means that you can see if there’s any correlation between users that viewed your video on your site and conversion.
You can drill even deeper and see how long users view the video on your site, either by seconds or by percentage.
For example, if you see that almost all users drop your video after 14 seconds, or after 20%, you might consider shortening your video, or changing the content where users have the highest probability to churn.

YouTube video tracking implementation

There are 3 simple steps you need to do in order to start tracking your YouTube video in Google Analytics.
1. Add the relevant Variables
2. Create the Tag that will fire the event hit to Google Analytics
3. Create the New Trigger for YouTube video tracking

1. Add the relevant Variables

Under the Variables, click on Configure, and add all relevant Video variables:
YouTube tracking in GTM creating variables
Video Provider: ‘youtube’ – This is the provider of the video. This means that they will probably make this available with other providers (Vimeo, Wistia, etc.)
Video Status: ‘start’, ‘complete’, ‘pause’, ‘buffering’, and ‘progress’ – This is the status of the video that caused the event to trigger.
Video URL: ‘https://www.youtube.com/watch?v=…’ – This is the URL of your embedded video.
Video Title: ‘YouTube video title’ – This is the title of your embedded video.
Video Duration: 122 – This is the total length of the video (in seconds).
Video CurrentTime: 43 – This is the current duration of the user that’s viewing now your video.
Video Percent: 25 – This is the percentage that the user reached from your video.
Video Visible: true – This may be true or false, it depends whether your video was visible in the browser viewport or not

2. Create the Tag that will fire the event hit to Google Analytics

Let’s create a new Universal Analytics tag. Choose Tracking Type: Event.
Uner the Categoru let’s insert “YouTube video” (you can inset here also just Video or YouTube)
Under the Action we will insert the Video Status variable, that may contain: ‘start’, ‘complete’, ‘pause’, ‘buffering’, and ‘progress’. We will concatenate to that : and then the Video Percent
Under the Label we will insert the Video Title, concatenate with : and the the Video URL
YouTube tracking in GTM - Creating the event tag

3. Create the New Trigger for YouTube video tracking

At the bottom of the tag we just created you will need to insert the trigger. In case you try to save the tag without adding a trigger you will receive the following message:
YouTube tracking in GTM - Alert for tag with no trigger
So Let’s create the new YouTube Video Trigger.
YouTube tracking in GTM - Creating the YouTube video trigger

Start – Will trigger when a user starts watching the video.
Complete – Will trigger when a user reaches the end of the video.
Pause, Seeking, and Buffering – Will trigger when a user pauses, seeks forward or backward, and when the video starts buffering.
Progress – Will trigger when a user passes either a percentage (e.g. 10%, 25%, 50%) or time threshold (e.g. 5 seconds, 15 seconds).
Advanced – Add JavaScript API support to all videos – The trigger will only fire on videos that have JS API support (i.e. requisite query parameter). Checking this will add the missing parameter to all videos on the page. Notice: This reloads the iframe, so when you just reload the page , you might see the video reloading twice.

Learn Google Analytics, at your own pace, from wherever you are, with the best platform!

Start the course now (free)