Dynamically Track YouTube Videos with Adobe Analytics – No Development Required

The Adobe Analytics YouTube Player Video Measurement Library will enable you to track video consumption on your site using the YouTube iFrame Player API. If you are comfortable using Adobe DTM, you can deploy all the code you need directly through DTM without having to make any code changes on your site.


  • YouTube videos deployed on your site using the iFrame embed option
  • Adobe DTM
  • Adobe Analytics AppMeasurement JS
  • 1 Prop, 3 eVars, and 7 Events

Data Collected:

  • Video Name
  • Video Segment
  • Video Start Event
  • Video Time Viewed
  • Video Segment Viewed
  • Video Played 25% Event
  • Video Played 50% Event
  • Video Played 75% Event
  • Video Complete Event

Adobe Analytics Setup

The first thing we will want to do is to go into Adobe Analytics and enable all of the variables we will use to track YouTube video consumption on our site. Navigate to Report Suite Admin and add/configure the following variables:

Variable Variable Name
propN1 Video Name
eVarN1 Video Name
eVarN2 Video Segment Name
eVarN3 Video Content Type
eventN1 Video Start
eventN2 Video 25%
eventN3 Video 50%
eventN4 Video 75%
eventN5 Video Complete
eventN6 Video Time Viewed
eventN7 Video Segment View


Update ALL YouTube Embeds On Your Site

Yikes! This part of the implementation has historically been a real challenge. The Adobe Analytics YouTube Library requires two attributes be present on every YouTube video on your site you wish to track — Every embedded YouTube URL needs to have ‘&enablejsapi=1’ appended to the query string of the video, this allows the Adobe Media Module to communicate with the YouTube API and each video needs an id of ‘playerN’, where N denotes a sequential number of the player if you have multiple videos embed on a page e.g. player1, player2, player3, etc.

So not only do you need to audit all of your pages to make these required changes and have the changes made before you can start tracking your YouTube Videos, you also need to remember to add these attributes with every new video you embed and if you forget, the video won’t be tracked.

Thankfully, utilizing the power of Adobe DTM, we have a way of automating this whole process. No going back and updating all your video embed code. No needing to remember to update your embed code for new videos you add to your site.

In Adobe DTM, within the Adobe Analytics configuration section, add the following code to your Custom Code. This code should appear before the rest of the video tracking code we will add next:

This block of code will dynamically add the required code to enable the YouTube JavaScript API to all of your YouTube videos. In addition, the player id will be dynamically created, based on the number of YouTube videos you have embed on each page, and applied to each player.


Add the Adobe Analytics Media Module Library

If you haven’t already, you will need to deploy the Adobe Analytics Media Module for YouTube tracking to work properly. This Module can be easily deployed using Adobe DTM. Copy and Paste the module into your Analytics Code Library, if you have it hosted in DTM, or update your Code library directly on your servers.

Add YouTube Tracking Modules

The final step is to add the required YouTube Tracking Modules, there are 3 of them, to Adobe DTM. I would recommend adding these blocks of code, in the order they appear, directly under the Adobe Analytics YouTube Player Video Measurement Helper Function code, again utilizing the Custom Page code function within Adobe DTM.

YouTube Player Mapping

YouTube iFrame JavaScript API

Add and Update the Adobe Analytics Media Module Configuration

NOTE: This section requires you to update the configuration to align with the variables we created earlier in this tutorial in order for the data collection to function properly.

And that is it! If you are familiar with Adobe DTM, you can utilize this process to deploy YouTube Tracking, using Adobe Analytics, across your entire site in less than an hour.

Jason Thompson
Jason is the co-founder of 33 Sticks. In addition to being an amateur chef and bass player, he can also eat large amounts of sushi. As an analytics and optimization expert, he brings over 12 years of experience, going back to being part of the original team at Omniture.