YouTube Video Tracking with Google Tag Manager

In September 2017, Google released native YouTube video tracking in Google Tag Manager (GTM), which makes setting up Google Analytics event tracking for YouTube super easy. This blog post shows the steps to add YouTube video tracking to GTM, or you can skip to the end and download and import the pre-configured setup into your own GTM container.

NEW! API CONNECTOR ADD-ON FOR GOOGLE SHEETS

Check out my new API Connector Add-on to import data from thousands of platforms (e.g. Shopify, Harvest, Mailchimp, ActiveCampaign, VWO, YouTube, etc.) directly into Google Sheets.

OVERVIEW

YouTube video tracking lets you track interactions with any YouTube videos on your site. This includes play, pause, watch 10%, watch 25%, watch to end, etc.

STEP 1: SET A YOUTUBE VIDEO TRIGGER 

Click New Trigger and choose Trigger Type = YouTube Video

youtube-tracking-img1

 STEP 2: CHOOSE TRIGGER OPTIONS

The native YouTube trigger comes with several options to choose from. By default “Start” and “Complete” are selected, but you can also choose to track actions like Pause and Progress if you like. I recommend enabling all the tracking options.

If you select “Progress” you can choose between percentages (percent of video watched) and time thresholds (how long someone watched). Here we’ll choose percentages, marking 25%, 50%, and 75% (100% will be tracked automatically using the “Complete” option).

We are also going to select Add JavaScript API support to all YouTube videos as in some cases the trigger won’t work without it.

youtube-tracking-img2

STEP 3: SET UP YOUTUBE VARIABLES

Click Variables > Built In Variables > Configure, and choose the options you need. For this example we will choose Video Status, Video Title, and Video Percent.

youtube-tracking-img3

You can choose other Variables if you prefer. These are examples of the output you will see from each Video Variable:

Variable Variable Type Return Type Example Values
Video Current Time Data Layer Variable number 17
Video Duration Data Layer Variable number 212
Video Percent Data Layer Variable number 8
Video Provider Data Layer Variable string youtube
Video Status Data Layer Variable string start, seek, pause, progress, complete
Video Title Data Layer Variable string Bag Raiders – Shooting Stars
Video URL Data Layer Variable string https://www.youtube.com/watch?v=feA64wXhbjo
Video Visible Data Layer Variable boolean true, false

STEP 4: SET UP GA EVENT TAG

Click Tags > New > Universal Analytics > Event and fill in Category, Action, and Label. In this example, our naming logic is:

Category = Videos
Action = {{Video Title}}
Label = {{Video Status}} – {{Video Percent}}%

Add the YouTube Interactions trigger from step 2 and save.

youtube-tracking-img4

STEP 5: TEST THE TAG

Click Preview mode and interact with your video to ensure the tags are firing as expected.

Here I’ll include an embedded video to test the output of the tag configuration above. Interact with the video and underneath you’ll see exactly what gets passed to GA.

Event Category =
Event Action =
Event Label =

CONCLUSION

In summary, we added a native YouTube trigger provided by GTM, and configured it along with with variables to track the video name, percent played, etc. We then used this trigger and variables to configure a Universal Analytics event tag that sends this information to GA.

YOUTUBE VIDEO TRACKING CONTAINER IMPORT

If you want to import this exact setup so you can begin tracking YouTube videos with nearly zero configuration (just add in your own UA tracking ID), you can download this container.

Following that, click Admin > Import Container > Choose Container File, and set as follows:

Choose Workspace = New
Choose an Import Option = Merge > Rename conflicting tags, triggers, and variables

youtube-tracking-img5

Setting as above will not change or interfere with any of your existing tags.

The only configuration option required is to edit your GA tracking ID in the UA – YouTube Video tag. Confirm and test in preview mode, then Publish so it merges into your main workspace.

GOOGLE TAG MANAGER CONSULTING

Get your own tag manager! Click for information on my Google Tag Manager consulting service.

Comments:1

Leave a Reply

Your email address will not be published.