Update time: January 15, 2025
In this section, I will share how to track YouTube video playback on the website.
- Enhanced Measurement Events: Enhanced Measurement has a built-in Video engagement that can track Youtube Video.
- Youtube Video Trigger: in fact, Google Tag Manager has a built-in Youtube Video Trigger, it is very easy to track using this trigger.
Suppose now to track the video on https://www.bbccss.com/youtube-test
Enhanced Measurement Events
GA4’s enhanced measurement events have built-in Video engagement, contains three events:
Measurement option | Events | Triggered… | Parameters |
Video engagement | video_start video_progress video_complete |
For YouTube embedded videos that have JS API support enabled, the following events are triggered:
|
video_current_time video_duration video_percent video_provider video_title video_url visible (boolean) |
In GA4 , click 「Admin」——「Data Streams」, open Web stream details:
And then click the Settings icon for Enhanced measurement, you will see “Enhanced measurement”:
Check 「Video engagement」 and click save, and you’re all set.
Read More : GA4 Event Tracking Series ② —— Enhanced Measurement Events
Youtube Video Trigger
Google Tag Manager has a built-in Youtube Video Trigger, it is very easy to track Youtube Video using this trigger.
Step 1 : Enable Built-In Variables
First enable some Built-In Variables, which will automatically get attributes to variables in GTM.
In GTM , click「Variables」——「Configure」,Check these Built-In Variables of click:
Click「Variable」——「Configure」 , check all the Video type variable:
Step 2 : Set Up the Trigger
In GTM , click「Triggers」——「New」——「Choose a trigger type to begin setup…」——「YouTube Video」,Name it “Youtube”, and make the following settings:
There are 4 types of Capture options:
- Start: Fires when the video starts playing
- Complete: Fires : when the video ends
- Pause, Seeking, and Buffering: If the video is paused, the scrub bar is moved, or if the video buffers, the trigger will fire.
- Progress: Fires at specified video progress points, configured by percentage or time threshold values:
- Percentages: This value indicates the percentage of the video that has been played. Enter percentages as a comma separated list of one or more integers. Example: 5, 20, 50, 80, which represents 5%, 20%, 50%, and 80% respectively.
- Time Thresholds: This value represents the number of seconds that the video has played. Enter time thresholds as a comma-delimited list of one or more integers. Example: 5, 15, 60, 120, which represents 5 seconds, 15 seconds, 60 seconds, and 120 seconds respectively.
- Advanced——Add JavaScript API support to all YouTube videos: Check this box to enable the YouTube iFrame Player API. If you are copying videos from Youtube, you don’t need to enable it.
- Enable this trigger on: Select the appropriate option, For best results Window Load (gtm.load) is the recommended option.
- Container Load (gtm.js) occurs as soon as possible when the page loads.
- Window Load (gtm.load) (default) occurs after all initial content on the page has loaded.
- DOM Ready (gtm.dom) occurs after DOM is ready to be parsed.
Step 3 : Set Up the Tags
In GTM , click「Tags」——「New」——「Choose a tags type to begin setup…」——「Google Analytics: GA4 Event」,Name it “GA4-Event-Youtube Video Tracking“, and make the following settings:
The event name here is video_{{Video Status}}, where {{Video Status}} is a built-in variable. For example, if the corresponding {{Video Status}} is start when playback starts, then the event name is video_start.
I have set an event parameter video_title here. You can set more. It is recommended to use the event parameter names already in Enhanced Measurement Events, such as video_current_time、video_duration、video_percent、video_provider、video_title、video_url、visible (boolean)
Step 4 : Preview and Publish
Next is the Preview test:
Tags is triggered and can be published.
Read More:
Step 5 : Custom Definitions
The next step is to register event parameters video_title , if you want to use it in GA4, you need to register it in the Custom definitions of GA4.
In GA4,click「Admin」——「Custom definitions」——「Create custom dimension」, then do the following configuration:
Step 6 : Verify Data in Reports
Generally, after 24 hours, we can see the data in GA4, such as: