June 1, 2021
Track Youtube Videos with Google Tag Manager and Google Analytics 4
Even though Google Analytics 4 offers built-in Video tracking (thanks to Enhanced Measurement), it does not always work on all websites. Also if you want to modify and change thresholds when video events are sent to GA4, you will need to create your own customized solution.
And in this blog post, I will show you exactly that. We’ll learn how to track Youtube videos with Google Tag Manager and Google Analytics 4.
I have created an extensive video tutorial where I explain various video tracking techniques (Youtube, Vimeo, etc.). So if you prefer video content, take a look at the tutorial below.
Trying the built-in tracking first
If you want to try the built-in video tracking in GA4, read this blog post. If that option does not work for you, then continue reading.
Anyway, if you choose to implement video tracking this way, you should disable Video Engagement tracking features in Enhanced Measurement. Otherwise, you will be at higher risk of occasional duplicate data (when the enhanced measurement is tracking the same things as your GTM setup).
Go to GA4 Admin > Data Streams > Gear Icon > disable Video Engagement tracking. After you did that, let’s continue with the setup.
Also, in this blog post, I presume that you have already installed GA4 in your GTM container. This means that you already have the GA4 configuration tag created.
#1. Create a Youtube Video Trigger
It all starts with a trigger. In Google Tag Manager, go to Triggers > New > Trigger Configuration and choose Youtube Video. Then enter the following settings:
You can change the Percentage threshold to anything you like, just separate them with a comma. Also, you can enable Pause, Seeking, and Buffering tracking. Personally, I prefer tracking Start, Complete, and Progress (e.g. 25% of the video was watched).
#2. Enable built-in video variables
In Google Tag Manager, go to Variables > Configure and enable all video-related variables.
#3. Create a Google Analytics 4 tag
Now, it’s time to send the Youtube video data to Google Analytics. In GTM, go to Tags > New > GA4 Event Tag and enter the following settings.
Some parts might be confusing so let me explain:
- You can enter whatever you want in the Event Name field. I was just trying to follow the same naming convention that is used by the Enhanced Measurement. In my setup, there will be 3 possible event names: video_start, video_progress, and video_complete. This is possible because of the built-in variable called “Video Status”.
- All the event parameters that I have included are also optional. If you think that some of them are not valuable, go ahead and remove that. I (once again) decided to follow the naming convention of Enhanced Measurement.
In the triggering section, I select the previously created Youtube video trigger.
#4 Test the setup
Once you have completed all previous steps, it’s time to test. Enable/Refresh the Preview and Debug mode, refresh the page on your website with the embedded Youtube video player and try to interact with it.
First of all, you should start seeing Youtube Video events in the preview mode. If you don’t see them, read this troubleshooting guide.
Click one of them and check whether your Google Analytics tag has fired.
If yes, then go to Google Analytics 4 DebugView to check if you see the incoming events.
After a while, your events data will appear in Standard Google Analytics reports and Analysis Hub as well. But that might take up to 24 hours. So be patient.
Also, don’t forget to register parameters as video_percent or video_title as custom dimensions (if you want to use them in your GA4 reports).
If the Youtube video trigger is not working, read this guide.
GTM recipe for Youtube tracking
Those who have been following Analytics Mania for a while know that I have compiled a library of ready-made GTM container templates (called recipes). A portion of those recipes also involves video tracking.
As you have probably guessed, Youtube video tracking is among them. Go to this page, download the needed files, and carefully read the installation/configuration instructions.
Track Youtube videos with Google Tag Manager and GA4: Final words
There are many ways how you can track videos with Google Analytics and Google Tag Manager. But those ways/methods depend on what kind of player are you dealing with.
If you are dealing with Youtube video players (and you want to track them with GA4), you can try the Enhanced Measurement first and if that does not work as you expect, follow all the steps that I’ve covered in this blog post.