How to Track YouTube Videos in Google Analytics 4

So you want to learn how to track YouTube Videos? 

This post shows how to track YouTube videos that you embed on your site or that you share as links elsewhere. 

To track YouTube videos, you will either rely on Google’s Enhanced Measurement which automatically tracks video engagement, or configure the tracking via Google Tag Manager.

Master the basics with our FREE GA4 Course for Beginners

Although the former approach seems convenient, its caveats often leave GTM as the most preferred option. 

We will cover how to quantify the consumption of YouTube video content on your website and measure the performance of YouTube as a traffic source.

The topics we’ll focus on:

Let’s dive in!

How to Track YouTube Videos in Google Analytics

There are 2 ways to track embedded YouTube videos in Google Analytics. We’ll cover them both with a focus on GA4. 

  1. You can simply enable the Video engagement option within Enhanced Measurement (which automatically tracks video interactions without any code).
  2. You can configure your tracking in Google Tag Manager (recommended).

The first option is okay if you’re not using Google Tag Manager yet. It only requires a bit of clicking here and there. 

However, for this to work, all your embedded videos must have the JS API support enabled which requires a modification of your YouTube embedded code. 

Also, this first option will limit you to default thresholds (such as the video progress for any user viewing passed 10%, 25%, 50, and 75% of the video), which can get in the way of setting your thresholds. 

Consequently, Google Tag Manager is the option of choice for many marketers. Using GTM is best practice, as you have more control over your data. 

🚨 Note: We recommend using GTM. However, whichever option you choose, make sure not to use both at the same time. If you decide to use GTM, disable Video engagement in Enhanced Measurement to prevent duplicate data in your reports.

How do you track videos on GA4? (Enhanced Measurement)

This approach is suited for YouTube videos that are embedded on your website. 

GA4 Enhanced Measurement allows tracking common events without the need for any code implementation. Unfortunately, it isn’t a magic wand for YouTube video tracking. 

That is because you’ll need to add the enablejsapi parameter to the source URL of the video and set it to 1. This is how it looks exactly: enablejsapi=1.

Here’s a practical example. Head to a YouTube video. Click Share.

Sharing a YouTube video to get the embed code

Then select Embed

Selecting the embedded YouTube code

Start by typing the question mark (?) and then add the parameter to the code enablejsapi=1

Adding the js API support to a YouTube video

Click copy, and embed this code on your website. Ours looks as follows:

<iframe width="560" height="315" src="https://www.youtube.com/embed/Ly-IHQhX4DU?enablejsapi=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

How Do I Track a YouTube Video With Google Tag Manager

Let’s start by building a trigger in Google Tag Manager. 

Go to Triggers and click New.

Creating a new trigger

For the Trigger configuration, select the YouTube Video trigger type. 

Selecting the Youtube video trigger type

Follow our next setup. 

Youtube video trigger configuration

There are occasions where video tracking may not work and one solution is to select Add JavaScript API support to all YouTube videos. So, we’ll keep it checked just in case.

This is a common setup that works for most people. But, it can be modified. At this moment, you’ll have to ask yourself or your team what you want to achieve with this trigger and what you want to measure. 

  • Are there specific pages or videos that you want to track? 

If yes, then you can achieve it by selecting Some Videos for when the trigger should fire. 

  • Do you need to track the video progress in percentages or in time?
  • Is capturing Pause, Seeking, and Buffering important to you?

Selecting this option will send an event each time a user clicks pause, seeks forward/back, or starts buffering.

Given the way we watch videos online, these events are likely to multiply very quickly and populate your GA4 unnecessarily. Therefore, If these events aren’t critical for your measurement, you can leave this option unchecked.

Now that you have a trigger, make sure that you’ve enabled the GTM’s built-in video variables. These will provide additional information about tracked videos.

Follow these steps: Variables → Configure

Configuring a new trigger in Google Tag Manager

In Configure Built-In Variables, scroll down to Videos and select all the variables.

Enabling all videos variable in Google Tag Manager

You can test your trigger quickly by enabling the preview mode in Google Tag Manager. We will use the welcome video embedded on our demo shop website.

Let’s preview the page by enabling the preview mode in your GTM Workspace.

Enabling the preview mode in Google Tag Manager

In Tag Assistant, add your page URL.

Connecting Tag Assistant to a site

Click Connect.

Play the video and skip to the end of the video, so we can see what data our trigger collects. 

In the debug interface, you should see 2 events in the left panel entitled YouTube Video. The first one fired when the video started playing, and the second was when the video was completed. 

YouTube video events in the debug summary

You can verify these statuses by selecting one of the events under the Summary bar. Then click Variables

Selecting the variables tab in the debug interface

Scroll down to Video Status and observe the value.

Video status variable in the debugview interface

Let’s create a new Tag to send this information to Google Analytics. 

Select Google Analytics: GA4 Event and use your GA4 settings variable for the Configuration Tag. 

🚨 Note: If you’re not familiar with the process of creating GA4 events, check out our Google Analytics 4 tutorial for beginners. It’ll take you through setting up an account, how to use Google Tag Manager, and create events for GA4.

Let’s now name our tag.

Naming Convention for YouTube Video Tracking

You can name your event however you wish. 

It is, however, best practice to first consider using existing event names either recommended by Google (called Recommended Events) or those listed in Enhanced Measurements before coming up with your own.

Let’s take a look at Enhanced measurement because there you’ll find more details on Video Engagement and Google’s event naming structure. 

Google Analytics can natively track 3 different types of engagement:

  • video_start
  • video_progress
  • video_complete

The good news is that Google Tag Manager has a variable known as Video Status, which you saw earlier. This variable shows these statuses depending on whether a user started, progressed, or completed a video. 

So, instead of sending 3 events for each, your event will streamline all of them into one event with the current status of users. 

This is how you do it. In your tag, in the Event name, type the word video followed by an underscore: video_

Google names all its events in lowercase and uses underscores to separate words. You should follow this convention.

First part of a YouTube video event name

Click the variable icon.

Clicking the variable icon in the tag configuration

In Choose a variable, select the Video Status dataLayer variable.

Selecting the video status datalayer variable

Now your Event name will be the following: video_{{Video Status}}

Example of the YouTube video status event name

You could consider the job done here. 

However, we’d like to add more details to the event we’re sending to GA4. These details are called parameters. 

What relevant details could you send to GA after users viewed a video? Again, we can get some inspiration from Google Analytics by looking at what parameters it tracks automatically with videos.

In the previous section, we looked at the Video Engagement section on the Enhanced measurement page. There you will not only see your option of video events but also the useful parameters that GA4 sends with it. 

These are:

  • video_current_time
  • video_duration
  • video_percent
  • video_provider
  • video_title
  • video_url
  • visible

We will use these to name our parameters. Choose those that will serve your measurement objectives. For our example, we will use all of them except for visible.

Copy and paste each into a separate row under Parameters.

Adding and naming video event parameters

Now we need to add their corresponding dynamic values. 

Luckily for us, these values also exist as variables in Google Tag Manager. They’re the same video variables we enabled when creating our trigger. 

To fetch them, click on the variable icon and select the matching variable for each. For example, to get the value for the video_current_time parameter, we will click the variable Icon. 

Adding a variable value to an event parameter name

Then select the Video Current Time dataLayer variable.

Selecting the video current time datalayer variable

Repeat the process for each. You should end up with the following:

Full event parameters configuration for YouTube event tag

Name and save your tag. 

Testing YouTube Video Tracking in Google Tag Manager

Click the Preview mode. Start and complete your video. 

This is what you can expect if your tag is fired properly.

YouTube video tag fired

To make sure everything works well on GA4’s side, head over to the DebugView in GA4. Here are the coming events. 

YouTube video events in debugview

To see the parameters we configured earlier, click on any of the events. We will click on video_complete

List of event YouTube event parameters

🚨 Note: All our parameters appear in the DebugView. However, to use them in your reports, you need to register them as custom dimensions. 

Let’s look at an example of how to register our tag’s parameters as custom dimensions. 

Copy a parameter. We will highlight and copy the Video title

Copying the video title parameter

Staying on the same page, go to Custom definitions in Configuration and click Create custom dimensions

Creating a custom dimension in GA4

In the Dimension name placeholder, write a relevant title. There is no naming convention here, so feel free to write your title any way you wish. 

Select Event for Scope. The Description box is optional. The most important step is what you add in the Event parameter. Paste the parameter you copied earlier. 

Here’s what everything should look like: 

Registering the video title parameter as a custom dimension

Click Save

These parameters will be ready within the next 24 hours in your GA4 reports. By then, you’ll be able to use them in your reports and your Explorations. 

Google Analytics can provide details on YouTube links shared anywhere online and that users click on. For this to work accurately, you’d need to use UTM tracking. 

UTM tracking consists of tagging your links by adding code to the end of your URL.

By tagging your traffic sources, you can know where viewers came from (email, paid ads, podcast, group share, etc. ), how they navigate throughout your website, and how well they convert. 

We designed a tool to help you tag your links fast with the support of our guide full of examples on how to use UTM tracking in the real world.

Lastly, you can evaluate your marketing efforts by determining how your YouTube channel compares to other traffic sources.

Google Analytics vs YouTube Analytics

We have often discussed the analytics features of Google Analytics for a good reason. It is the most popular analytics platform in the world. 

However, YouTube is owned by Google, and it comes as no surprise that its analytics capabilities are powerful and quite similar to those of Google Analytics.

YouTube offers robust and detailed reports about the views, engagement, traffic sources, and demographics of visitors to your channel. You can view these reports within YouTube Analytics. 

If you’re using YouTube as your main marketing channel, then its analytics are what you need to measure your success.

Now the question is – what’s the point of using Google Analytics to track YouTube videos?

There are a few reasons why you might want to use Google Analytics over YouTube’s native analytics. First, they are mostly all tied to understanding and measuring online behaviors outside of your YouTube channel.

Second, in today’s multi-touch marketing world, these reasons explain the need to have a global view of all your marketing efforts across different channels in one place for a global analysis. 

This is not limited to Google Analytics, but also other platforms like BigQuery for example. 

Google Analytics is a great option if you conduct a lot of your business through an online website because you likely don’t rely on YouTube as a primary marketing channel. 

You might want to track and uncover insights unavailable in YouTube’s analytics dashboard, such as tracking visits to a blog post or another piece of content that lives on your site but isn’t a video.

If the goal is to understand how visitors coming from YouTube interact with your site, how engaged they are once there, and how they convert, then you want to look at Google Analytics via YouTube video tracking. 

Google Analytics will help you also determine how YouTube as a channel holds up against other channels using attribution modeling

Summary

The next time you have a YouTube video you want to track, you’ll know exactly what to do. You can always come back and refer to this post. 

In the future, we’ll continue to post more ways to track other video-sharing platforms on your sites, so keep checking back.

Continue your learning journey and check out our handy guide on how to track site search in GA4.

JOIN US!

Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more

Related Posts

guest
0 Comments
Inline Feedbacks
View all comments

Blog Categories

Want to turn your skills into a profitable investment? Subscribe & Get our FREE Course

How to Sell GA4 FREE Course

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.