How to Track Videos in Google Analytics using Google Tag Manager

how to track videos in google analytics using google tag manager

Jump To:

Videos take a lot of time and effort to create so it’s especially important that you can track video engagement in Google Analytics once you’ve added those videos to your website. Luckily, it’s pretty easy to track videos using Google Tag Manager (GTM). 

In this guide, we are going to show you how to easily track video plays, pauses, completions, and progress in Universal Analytics and Google Analytics 4 using GTM. While there are several other video hosts, such as Vimeo, we are going to focus on tracking embedded YouTube videos and HTML5 videos. HTML5 videos are most likely self-hosted videos that were uploaded directly to your website platform, such as WordPress.

Jump To

Identifying Your Video Host

In order to track your video engagement, we must first determine your video host. It may already be pretty obvious if your video is hosted on YouTube or one of the other bigger players, but if it’s not, right-click on the video and click inspect or press F12. This will bring up the HTML code in your browser’s DevTools panel. 

Don’t worry! Even if you’re not a developer, you don’t need to be scared by the DevTools panel. We’ll show you exactly how to use it.

Navigate to the Elements tab to look for your video. If you can’t find your video right away, you may need to expand some other elements to show the elements nested inside.  Mousing over different parts of the HTML code in your DevTools will highlight the corresponding element on your website which should help you narrow down to find your video. You can also use the Inspect tool as seen in the picture below.

DevTools inspect feature
Use Right Click + Inspect or press F12 to pull up DevTools in Chrome. From there, you can use the Inspect tool to mouse over elements on the website and find its node on the Elements tab of DevTools.

Your video will probably be in an <iframe> or a <video> node and it may even say the name of the video host. 

If you don’t see an <iframe> and your domain is listed after the “src=” attribute of your video, the video is self-hosted. This means it was probably just uploaded to your website CMS’s media library instead of another video host like YouTube. If this is the case, skip down to the next section to track self-hosted html5 videos.

src attribute for self-hosted video in DevTools
This MP4 video file is a self-hosted HTML5 video player because the src attribute shows the domain. For example, if we are on, then we would see “src=”

If you see “” in the src attribute, like in the screenshot example below, then you’re in luck because Google Tag Manager makes it easy to track videos hosted on YouTube.

youtube video embedded in iframe in DevTools
In this example, this video is hosted on YouTube, which can be seen in two places: once in the src attribute and once in the class of the parent <div> above it.

YouTube Video Tracking In GTM

To save you even more time, we created a GTM recipe to automatically create Google Analytics events for YouTube videos, instead of setting everything up from scratch. This recipe is meant for Universal Analytics because Enhanced Measurement in Google Analytics (GA4) automatically tracks YouTube videos.

GTM youtube events trigger
Our GTM Recipe for tracking YouTube videos on your website creates events for Plays, Completions, and each 25% of progress

To make it easier for you to set up, we’ve created a GTM recipe that you can import into your GTM container. A GTM Recipe is just a small JSON file that can be more easily shared and added to other GTM containers. We use them a lot when setting up tracking and tagging for our clients because a lot of this stuff is reusable.

To import this recipe into your GTM container, download our YouTube Video tracking GTM Recipe using the button below and follow the import instructions near the end of this article.

GTM Recipe: YouTube Video Tracking

import YouTube event recipe in GTM
This is what your YouTube recipe import should look like in GTM.

Tracking Self-Hosted HTML5 Videos in Universal Analytics & Google Analytics 4 Using GTM

Besides uploading a video on YouTube, another common method of adding a video to your website is by uploading it into your website’s Content Management System (CMS) and hosting it on your domain. 

Unfortunately, the built-in GTM variable used in the above method only works for tracking YouTube videos. In order to track HTML5 video engagement in Google Analytics, we need to create a custom HTML tag in Google Tag Manager with an auto-event listener in it. If that sounds too complicated, feel free to just jump down to our (free) HTML5 Video GTM recipe below for easy setup and start tracking your HTML5 videos in Google Analytics

Now, before going any further, we’d like to give a shout-out to Julius Fedorovicius and David Vallejo. In 2014, David published the original version of the auto-event listener tag that’s used to power the HTML5 Video Tracking GTM Recipe, and Julius modified that GTM recipe to track HTML5 videos in Google Analytics 4. Julius’s website also has individual GTM recipes for tracking HTML5 videos on each version of Google Analytics. 

However, instead of 2 separate GTM recipes, we are going to take it a step further and use one upgraded GTM recipe that creates HTML5 video events in Universal Analytics and also Google Analytics 4. This reduces the number of tags and variables so that your website is faster and your GTM container easier to maintain. 

GTM Recipe: Our Upgraded HTML5 Video Tracking Recipe for Universal Analytics And Google Analytics 4

To import our upgraded recipe for tracking HTML5 video engagement,

  1. Download our upgraded HTML5 video recipe
  2. Log into
  3. From the Admin section, click “Import Container”
  4. Choose the JSON file you saved to your computer
  5. Add which GTM workspace you’d like to add the recipe to (If you don’t know, choose “Existing”)
  6. Choose Merge as the import option and make sure that there are 0 modified or deleted items. If you see any modified or deleted items, select “Rename conflicting tags, triggers, and variables” instead.
  7. After clicking Confirm, test your new YouTube events using GTM’s Preview mode and Publish the container when ready. 
Combined HTML5 Videos Recipe For Google Analytics 4 and Universal Analytics by Intigress

If you’ve done it correctly, you should see both the Universal Analytics and Google Analytics 4 events firing on video engagements. In Universal Analytics, it will look like this:

Unviersal Analytics video events
Universal Analytics will display Video as the event category, and the progress as the event action

And here’s what it looks like in Google Analytics 4.

Google Analytics 4 video events
Google Analytics video events have additional parameters too

If you have any difficulties at all or it’s not working for you, feel free to contact us for assistance tracking videos in Google Analytics using Google Tag Manager or for other tracking and tagging assistance.

Have questions or found this helpful? Let us know in the comments below! 

Share This Article

Share on facebook
Share on linkedin
Share on twitter
Share on reddit
Share on email

Leave a Reply

Your email address will not be published. Required fields are marked *