Google Tag Manager YouTube Video Tracking via YouTube Video Trigger

Table of Contents for Google Tag Manager YouTube video tracking + Vimeo

  1. Introduction to Google Tag Manager YouTube video tracking
  2. Setting up video tracking via YouTube video trigger in Google Tag Manager
  3. Setting up Vimeo video tracking using Google Tag Manager
  4. FAQ

Today I am going to show you how to use the YouTube Video trigger in Google Tag Manager to track YouTube videos embedded on a webpage. We will also see how to track Vimeo videos.

Introduction to Google Tag Manager YouTube Video Tracking

The tracking method which is used to track/capture the various player states of an embedded video is called ‘video tracking’.

A player state is specific user interaction with a video.

Following are the example of various player states which can be captured for YouTube videos via GTM:

#1 Start – denotes video is playing.

#2 Pause – denotes video is paused.

#3 Seek – denotes scrub bar is moved to seek or reposition timing within a video.

#4 Buffering – denotes video buffering / downloading.

#5 Progress – denotes the progress of a specific video by percentage or time threshold. For example, if 5% of the total video length has been played then the value of Progress can be 5%. Similarly, if 10 seconds of video has been played then the value of Progress can be 10 seconds.

#6 Complete – denotes a video finished playing.

Setting up Video Tracking via YouTube Video Trigger In Google Tag Manager

Follow the steps below:

Step-1: Login to your Google Tag Manager (GTM) account and then click on the ‘Folders’ tab:

Folders in GTM

Step-2: Click on the ‘New Folder’ button.

Step-3: Name your new folder ‘YouTube Video Tracking’ and then click on the ‘create’ button. We are going to use this folder to store all tags, triggers and variables related to YouTube Video tracking.

Step-4: Click on the ‘Variables’ tab:

Vairables in GTM

Step-5: Click on the ‘Configure’ button:

configure built in variable button

Step-6: Scroll down and then select all the built-in variables related to videos:

  1. Video Provider
  2. Video Status
  3. Video URL
  4. Video Title
  5. Video Duration
  6. Video Current Time
  7. Video Percent
  8. Video Visible
configure video varaibles

Step-7: Click on the ‘New’ button under the ‘User Defined Variables’ column:

new user defined variabe

Step-8: Create a new dataLayer variable with the following configuration and then move the variable to the folder named ‘YouTube Video Tracking’:

Video elapsed time variable

This dataLayer variable is used to pull the value of gtm.videoElapsedTime from the dataLayer.

The gtm.videoElapsedTime dataLayer variable reports on the time elapsed (in seconds) since the last time a video was paused or buffered.

Later when we create a new universal analytics tag to send video tracking data to GTM, we are going to call this dataLayer variable within the tag.

Step-9: Create a new lookup table variable (name it ‘Video Player State’) with the following configurations and then move the variable to the folder named ‘YouTube Video Tracking’:

look up table video

I have created this variable to rewrite the outputs of the ‘video status’ variable. 

The ‘video status’ variable is a built-in GTM variable that returns the current video player state.

By re-writing the values of the current player state, I am making the video tracking report in Google Analytics more meaningful for the end-users (like my clients) who might not understand what ‘progress’ means or what ‘start’ stands for etc.

Step-10: Click on the ‘Triggers’ tab:

triggers in GTM

Step-11: Click on the ‘New’ button to create a new trigger.

new trigger

Step-12: Name your new trigger as ‘YouTube Video Trigger’ and then move the trigger to the folder named ‘YouTube Video Tracking’ (by clicking on the folder icon next to the trigger name):

move trigger to youtube folder in gtm

Step-13: Choose ‘YouTube Video’ as trigger type:

choose trigger type as youtube

Your screen should now look like the one below:

youtube trigger

Step-14: At this point, you need to decide your video tracking setup:

  • Whether or not you want to measure ‘Pause’, ‘Seeking’, ‘Buffering’ and/or ‘Progress’ Player states.
  • When the progress of videos should be measured?
  • How the progress of videos should be measured? In terms of percentages or time thresholds?
  • Whether or not you want to add JavaScript API support to all YouTube videos
  • What pages the ‘YouTube Video’ trigger should fire.

You can either decide your own video tracking setup or you can use the one I use:

youtube trigger settings

Here, I am measuring all available player states of a YouTube Video.

The progress of my videos should be measured whenever a user passes the following percentage thresholds: 10,25,50,75,90

Add JavaScript API support to all YouTube videos. 

The YouTube Video Trigger will fire on all pages of my website.

Step-15: Click on the ‘Save’ button to complete the creation of the new trigger.

Step-16: Click on the ‘Tags’ tab:

Tags in GTm

Step-17: Click on the ‘New’ button to create a new tag.

new tag


Step-18: Name the new tag ‘Send YouTube Video Tracking data to GA’ and then move it to the folder named ‘YouTube Video Tracking’.

Step-19: Set up the new tag with the following configuration:

Youtube tag configuration 1
Youtube tag configuration 2
Youtube tag configuration 3

We are going to use this tag to send the video tracking data to Google Analytics.

Step-20: Set the firing trigger of the ‘Send YouTube Video Tracking data to GA tag to the ‘YouTube Video Trigger’ we created earlier:

set trigger

Step-21: Click on the ‘Save’ button to complete the tag set up.

Step-22: Click on the ‘Preview’ button (on the top right-hand side) to preview and test your new video tracking setup:

preview

It will open a new tab with a pop-up like below. Provide the URL where the YouTube video is present and click on ‘Connect’.

connect

Step-23: It will open the provided URL in a new tab. Navigate back to the preview window and you should see the status as ‘Connected’. Now click on ‘Continue’.

continue

You should see a ‘preview’ of events in the ‘Summary’ column available on the left-hand side.

GTM preview mode

Step-24: Now play, pause and/or seek the embedded YouTube video.

As you interact with the video player, you should see the new ‘YouTube Video’ event(s) being listed….one after the other under the ‘Summary’ column:

youtube event in GTm summary

Step-25: Click on one of the ‘Youtube Video’ events and then click on the ‘Data Layer’ tab:

Click on youtube event and datalayer

Step-26: Now look at the values of the following data layer variables:

youtube event details in data layer

 

gtm.video‘ is the name of the event that activates the YouTube Video trigger.

VideoProvider‘ variable returns the name of the video platform whose videos you are tracking. Its value is ‘youtube’.

VideoStatus‘ variable returns the current player state of a video. Its values can be: start, complete, pause, seek, buffering and progress.

VideoUrl‘ variable returns the URL of the embedded video.

VideoTitle‘ variable returns the the title of the embedded video.

VideoDuration‘ variable returns the total length of the embedded video in seconds.

VideoCurrentTime‘ variable returns the time (in seconds) where a user was when the last video event fired.

VideoElapsedTime‘ variable returns the time elapsed (in seconds) since the last time the video was paused or buffering.

VideoPercent‘ variable returns the percentage of the total video length where a user was when the last video event fired.

VideoVisible‘ variable returns either true or false, depending on whether or not the embedded video was visible in the viewport when the last video event fired.

If you see the values of the data layer variables then it means, YouTube video tracking is working correctly.

Step-27: Click on the ‘Submit’ button (on the top right-hand side):

submit

Step-28: Enter your version name and then click on the ‘Publish’ button.

Step-29: Navigate back to the web page on your website which has got a YouTube video embedded on the page. Now play, pause and/or seek the embedded YouTube video.

Step-30: Wait for 10-15 minutes and then navigate to ‘Behavior’ > ‘Events’ > ‘Top Events’ report in your Google Analytics view:

Top Events

Step-31: Find and click on ‘YouTube Videos Tracking’ event category:

Events in Ga

In this event category you can find all of your video tracking data:

Event label

You can also track YouTube videos without using the YouTube video trigger.

To learn more about this tracking method, read this article: YouTube video tracking via Google Tag Manager

Do you want expert help in setting up/fixing GA4 and GTM?

If you are not sure whether your GA4 property is setup correctly or you want expert help migrating to GA4 then contact us. We can fix your website tracking issues.

Setting up Vimeo video tracking using Google Tag Manager

If you are using Vimeo videos on your website, you can track those video events using Google Tag Manager.

The first step in tracking Vimeo videos is to integrate the Vimeo player with Google Tag Manager to receive the video events. The second step will be configuring Google Tag Manager to send events to Google Analytics.

Follow the below steps to learn more.

Step-1: Navigate to your Vimeo vide account settings and click on ‘Marketing’.

vimeo marketing

Step-2: Now scroll down to the bottom and you will see a tracking script under Google Analytics. Copy this script and keep it for further steps.

Vimeo tracking code

Step-3: Navigate to your Google Tag Manager account and click on ‘Tags’.

Tags in GTm 1

Step-4: Now click on ‘New’ to create a new tag, name it as ‘Vimeo Tracking Code’ and then click on ‘Tag Configuration’.

vimeo tag configuration

Step-5: Now select tag type as ‘Custom HTML’.

customhtml

Step-6: Now paste the script that we copied earlier in the code window.

vimeo code in html

Step-7: Now click on ‘Triggering’ to create a trigger.

click on trigger

Step-8: Now click on the ‘+’ button to add a new trigger.

plus button to add new trigger

Step-9: Add you trigger a name ‘Video Vimeo Trigger- Dom Ready and select trigger type as ‘Page View – DOM Ready’.

dom ready trigger

Step-10: Select ‘All DOM Ready Events’ and then click on ‘Save’.

save trigger

Step-11: You will be navigated to the Tag configuration window. Click on ‘Save’ again.

Step-12: Now we need to confirm if the Vimeo tracking script is loading or not. Click on the Google Tag Manager Preview button.

preview 1

It will open a new tab with a pop-up like below. Provide the URL where the Vimeo video is present and click on ‘Connect’.

connect 1

Step-13: It will open the provided URL in a new tab. Navigate back to the preview window and you should see the status as ‘Connected’. Now click on ‘Continue’.

continue

You should see a ‘preview’ of events in the Summary column available on the left-hand side.

Step-14: Click on ‘Vimeo’ in the summary tab and then click on ‘Data Layer’.

vimeo event in GTM

Step-15: You should be able to see a ‘Vimeo’ event with the following details:

  • event: ‘vimeo’,
  • event_category: ‘Video’,
  • event_action: ‘load’,
  • event_label: ‘Sample Video | 253989945’ }
vime tracking working

If you can see this message, you have successfully set up a Vimeo tracking script on your website.

Now before we start tracking Vimeo video events, we need to create three user-defined variables, a custom trigger, and a tag.

Step-16: Now navigate to the ‘Variables’ tab in the GTM console and click on ‘New’ under ‘User-Defined Variables’.

new user defined variabe

Step-17: Give the variable name as ‘Event Category’ and select variable type as ‘Data Layer Variable’.

Event Category Variable

Step-18: Now under ‘data Layer Variable Name’ type ‘event_category’ and then click on ‘Save’.

save variable

Step-19: Similarly, create the remaining two variables as per the below configuration:

Variable 2

  • Name: Event Action
  • Variable Type: Data Layer Variable
  • Data Layer Variable Name: ‘event_action’
  • Data Layer Version: Version 2
Event Action

Variable 3

  • Name: Event Label
  • Variable Type: Data Layer Variable
  • Data Layer Variable Name: ‘event_label’
  • Data Layer Version: Version 2
Event Label variable

Step-20: Now let’s create a trigger for Vimeo events. Navigate to ‘Triggers’ in Google Tag Manager and click on ‘New’.

new trigger

Step-21: Give a name to your trigger, such as ‘Vimeo Events’, and then select the trigger type as ‘Custom event’.

Vimeo events

Step-22: Now under ‘Event Name’ type ‘vimeo’ and then click on ‘Save’.

save trigger vimeo

The following event actions are sent from the player and will be tracked:

  1. load
  2. play
  3. progress – 25%
  4. progress – 50%
  5. progress – 75%
  6. progress – 100%
  7. emailcapture

If you want to track only a few of the above events, you can request it to fire on some events only, by specifying the required events in the trigger condition.

specific events vimeo

Step-23: Now navigate to the ‘Tags’ tab in Google Tag Manager and click on ‘New’.

new tag

Step-24: Give your tag the name ‘Vimeo Video Events’ and select the tag type as ‘Google Analytics- Universal Analytics’ and track type as ‘Event’.

Vimeo tag events

Step-25: Now under ‘Event Tracking Parameter’, you need to link the data layer variables created earlier like below

  • Category: Event Category
  • Action: Event Action
  • Label: Event Label
link variable

Step-26: Select your Google Analytics tracking Variable in ‘Google Analytics Setting’ and then click on ‘Triggering’.

Click here

Step-27: Now select the custom event trigger that we created earlier ‘Vimeo Events’.

custom events

Step-28: Now click on ‘Save’ to save the tag configuration.

save tag

Step-29: Now let’s debug and validate the Vimeo video events using Google Tag Manager preview mode. Click on the ‘Preview’ button (on the top right-hand side) to preview and test your new Vimeo video tracking setup:

preview 1

It will open a new tab with a pop-up like below. Provide the URL where the Vimeo video is present and click on ‘Connect’.

connect

Step-23: It will open the provided URL in a new tab. Navigate back to the preview window and you should see the status as ‘Connected’. Now click on ‘Continue’.

continue

You should see a ‘preview’ of events in the ‘Summary’ column available on the left-hand side.

GTM preview mode 1

Step-24: Now play, pause and/or seek the embedded Vimeo video.

As you interact with the video player, you should see the new ‘Vimeo’ event(s) being listed….one after the other under the ‘Summary’ column:

vimeo event in gtm preview

Step-25: Now click on an of the event and then click on ‘Data Layer’. You can also see that the ‘Vimeo Video Events’ tag is fired.

vimeo event firing

Once you click on Data Layer you should be able to see event details, as below:

vime tracking working 1

Congratulations!!! You have successfully set up Vimeo Video Events.

Now navigate to Google Analytics console and under ‘Real-time > Events’ you should be able to see data flowing in Google Analytics.

GA Real time
  1. How to see Organic Search Keywords in GA4 (Google Analytics 4)
  2. Google Analytics Ecommerce Tracking Tutorial
  3. Google Tag Manager Event Tracking Tutorial
  4. Google Analytics Event Tracking Tutorial
  5. Google Analytics Store Visits Tracking Tutorial
  6. Offline Conversion Tracking in Google Analytics – Tutorial
  7. Ecommerce Tracking Google Tag Manager (GTM) – Tutorial
  8. Tracking Virtual Pageviews in Google Tag Manager – Tutorial
  9. Google Tag Manager YouTube Video Tracking
  10. Google Analytics Virtual Pageviews Tutorial
  11. Google Analytics YouTube Integration & Analysis Tutorial
  12. Google Analytics for Facebook Tutorial
  13. Cross Domain Tracking in Google Analytics – Complete Guide
  14. How to use two Google Analytics codes on one page
  15. How to correctly use referral exclusion list in Google Analytics
  16. Google Analytics Calculated Metrics – Tutorial
  17. Creating your own Google Analytics Tag Auditing System
  18. Google Tag Manager Search Tracking without Query Parameter
  19. Tracking Google Analytics Paypal Referral and other payment gateways
  20. How to Track Phone Calls in Google Analytics 4 – Call Tracking Tutorial
  21. How to track leads in Google Analytics via CRM
  22. Postbacks in Google Analytics Explained
  23. Subscription & Recurring Revenue Analytics in Google Analytics
  24. Track the Impact of Google Analytics Cookie Consent on Website Traffic
  25. Tracking Offline Conversions in Google Ads
  26. Implementing Scroll Tracking via Google Tag Manager
  27. Scroll Depth Tracking in Google Tag Manager – Tutorial
  28. Site Search Tracking In Google Analytics Without Query Parameters
  29. Google Tag Manager Youtube Video Tracking via YouTube Video Trigger
  30. How to Correctly Measure Conversion Date & Time in Google Analytics
  31. Google Analytics Social Tracking – Twitter, Facebook, Google Plus and LinkedIn
  32. Cross Domain Tracking in Google Analytics – Complete Guide
  33. Google Analytics Linkedin & Twitter Tracking
  34. Creating Content Group in Google Analytics via tracking code using gtag.js
  35. Google Analytics Site Search Tracking via Query Parameters
  36. Google Analytics Site Search Tracking Tutorial
  37. Creating and Using Site Search Funnel in Google Analytics
  38. How to add Facebook Pixel to Google Tag Manager
  39. AMP Google Analytics Tracking – Learn to track AMP pages
  40. Setting up Sales Funnel across websites in Google Analytics
  41. Google Analytics 4 Regex (Regular Expressions) Tutorial

Frequently Asked Questions About Google Tag Manager YouTube video tracking + Vimeo

How do you track YouTube videos using Google Tag Manager?

To track YouTube videos using Google Tag Manager you need to follow the below steps:
1. Enable Built-in Variables for YouTube Video in GTM
2. Create a user-defined data layer variable “Video Elapsed Time” with variable name as “videoElapsedTime”.
3. Create a new lookup table variable and specify the event’s output
4. Create a YouTube Trigger and specify the event you would like to track (start, complete, pause, seeking, buffering, and progress)
5. Create a YouTube Tag for Google Analytics
6. Test the Tag using the preview mode.

How many YouTube events can be tracked in Google Analytics?

You can track the following YouTube video events in Google Analytics.
– Start – denotes video is playing.
– Pause – denotes video is paused.
– Seek – denotes scrub bar is moved to seek or reposition timing within a video.
– Buffering – denotes video buffering / downloading.
– Progress – denotes the progress of a specific video by percentage or time threshold. For example, if 5% of the total video length has been played then the value of Progress can be 5%. Similarly, if 10 seconds of video has been played then the value of Progress can be 10 seconds.
– Complete – denotes a video finished playing

What is the similarities and difference in YouTube video and Vimeo Video?

Below points provides you overall similarities and difference in YouTube video and Vimeo video.
Video Viewing: Both video platform provides video viewing facility.
– Video Uploading: Both platforms provides you with the facility to upload videos.
– File Size: In YouTube, you can upload videos up to 20 GB (free) and in the case of Vimeo, you can upload only up to 500 MB (free). After 500 MB of space Vimeo is chargeable.
– Video Quality: With YouTube, you can use video quality as HD up to 1080p, HDR, 4K, 8K. while in Vimeo you can use HD quality video up to 720 pixels

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade