How to track You Tube video events using google tag manager ?

Posted in Uncategorized By Raj On September 11, 2016

In this article I am going to explain how to track you tube video events such as play, pause, end etc… using google tag manager

What is google tag manager ?  with tag manager we do not need to add tags manually to a website or page, you can directly create tags and  specify when it should be fired, this helps marketing people no need of depending on developer to add tags to a website and it will reduce the download time of page

Now, I am going to explain how to track customer behavior on “who moved my cheese” video, the customer behavior is something that how many people have seen complete video and how many people have seen only 20% of video etc…

Integrate GTM with you tube video :

The first step is you must include tag manager container snippet below the body tag of all your pages or any page which you want to track

Create a tag manager container :

  • login to
  • click on create account
  • Add account name
  • Enter container name
  • Select where you are going to place this container snippet, select web then click on create

Next, I am going to create “Track Video Player” tag and tag type for this is Custom HTML Tag, in the HTML section copy and paste below JavaScript code and select trigger type “trackVideo”



Create Tags :

  • Login to
  • Select Workspace tab
  • Click on tags which appears on left side navigation


Click on New button which appears on main pane


Now, a new window will open it will ask you select tag type, just select custom html and replace”Untitled Tag ” with “Track Video Player”


In the custom HTML section copy and paste below code


Triggers :

Click on triggers on left navigation


Click on new then a window will open which will ask you enter trigger details

In the below picture in the event name text box ,please enter name of the event which you are going to place in dataLayer object

You can select when this trigger should fire by selecting radio buttons, if you select some custom events then you need to apply condition, or if you select all custom events then it will fire for all events, then set references to this trigger is “Track Video Player” Tag


Variables :

It is time to create variables, you can create variable by selecting Variables on left side navigation, then click on new button, it open a window to enter variables related information

You need to select variable type to dataLayer Variable and provide variable name “videoState” repeat same thing for videoTitle datalayer variable


Once tags, triggers and variables are finally we need create a tag for universal analytics, once it is created then reference it to the “trackVideo” event

Create GA tag :

Create a new tag and select tag type to “Universal Analytics”

Enter tracking ID, the tracking ID you can get by login to Google Analytics, select Admin -> Tracking Info -> Tracking Code

Select tracking parameters videoState and videoTitle and reference type is “trackVideo”


Entire setup is you can test this by installing chrome plugin’s , I have tested this using GTM debugger and you will see something like below when you click on pause button of video player