Videos take a lot of time and effort to create so it’s especially important that you can track video engagement once you’ve added those videos to your website. Luckily, it’s pretty easy to track videos in Google Analytics 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, Vimeo videos, and HTML5 videos. HTML5 videos are most likely self-hosted videos that were uploaded directly to your website platform, such as WordPress.
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 Dev Tools 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.
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 in Google Analytics.
If you see “youtube.com/embed” 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.
If you see “player.vimeo.com/video/” in the src attribute, like in the screenshot example below, then skip down to the last section to track Vimeo videos in Google Analytics.
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 automatically tracks YouTube videos in Google Analytics 4 (GA4).
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.
GTM Recipe: YouTube Video Tracking
To import this recipe into your GTM container, download our YouTube Video tracking GTM Recipe using the button below and follow the import instructions in the HTML4 video tracking section or check out our more detailed guide to importing a GTM container.
Tracking Self-Hosted HTML5 Videos in Universal Analytics & Google Analytics 4 Using GTM
Besides uploading a video on YouTube or Vimeo, 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 is 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,
- Download our upgraded HTML5 video recipe
- Log into tagmanger.google.com
- From the Admin section, click “Import Container”
- Choose the JSON file you saved to your computer
- Add which GTM workspace you’d like to add the recipe to (If you don’t know, choose “Existing”)
- 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.
- After clicking Confirm, test your new YouTube events using GTM’s Preview mode and Publish the container when ready.
Vimeo Video Tracking In GTM
Of these GTM recipes, Vimeo video tracking is the most complicated because its event listener doesn’t work the same as the other two. With a little bit of Intigress magic, we ensured that our Vimeo GTM recipe fires events in Universal Analytics and Google Analytics 4 (GA4) with the same names as the other recipes on this page. This gives you clean data even if you need to use more than one of the recipes on this page. We’ll spare you the dirty details on how we did this and get right to it.
GTM Recipe: Vimeo Video Tracking
To import this recipe into your GTM container, download our YouTube Video tracking GTM Recipe using the button below and follow the import instructions above in the HTML5 section or we also have a more in-depth guide on importing a GTM Recipe.
One last thing. Because of the way the Vimeo event listener works, this GTM recipe will fire a
video_start GA4 event and a UA event with a
start Event Action every time a video is played (which could be more than once). Because of this we also set the triggers so they won’t fire any “pause” events since there are no corresponding “play” events. If you would like to track pause events, you can add “pause” to the custom event trigger’s RegEx.
Video Tracking Events In Google Analytics
Our recipes are designed to be compatible with each other so that naming conventions are the same. No matter which recipe you used for your video eventing, you should see events firing on video engagements in both Universal Analytics and Google Analytics 4.
Don’t forget to update the recipes to make sure you’re using the correct tracking ID or Measurement ID.
In Universal Analytics, your events will look like this:
And here’s what they look like in Google Analytics 4.
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!