Sub topic 7
Video Engagement for Embedded YouTube Players
Assume that you already have a GA4 property, a web data stream, and the Google tag installed through gtag.js or Google Tag Manager. You should also understand that GA4 records interactions as events with parameters. This chapter focuses on YouTube videos embedded in web pages.
GA4 enhanced measurement can automatically record engagement with supported embedded YouTube players. You do not need to write a separate click handler for the usual start, progress, and completion milestones. The video must use YouTube's JavaScript API. Add enablejsapi=1 to the embedded player's URL:
<iframe
width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID?enablejsapi=1"
title="Product walkthrough"
allowfullscreen></iframe>Replace VIDEO_ID with the video's actual YouTube ID. The player must be an embedded YouTube player, not merely a link to youtube.com.
Events and parameters
GA4 sends three automatically collected events:
| Event | When it fires | Typical `video_percent` value |
|---|---|---|
| `video_start` | The viewer starts playback | 0 |
| `video_progress` | The viewer reaches a progress milestone | 10, 25, 50, or 75 |
| `video_complete` | The viewer reaches the end | 100 |
Each event can include parameters that describe the player and the viewer's position. Common parameters include:
video_current_time: The current position in seconds.video_duration: The total video length in seconds.video_percent: The percentage milestone reached.video_provider: UsuallyYouTube.video_title: The title reported by the player.video_url: The URL of the video.
The exact event payload can vary by player configuration and implementation. Inspect the payload in DebugView rather than assuming that every parameter is populated in every situation.
sequenceDiagram
participant V as Viewer
participant Y as YouTube player
participant G as Google tag
participant A as GA4
V->>Y: Starts or watches video
Y->>G: Reports playback milestone
G->>A: Sends video_start or video_progress
Y->>G: Reports end of playback
G->>A: Sends video_completecaption: How an embedded YouTube player produces GA4 video events alt: A sequence showing a viewer interacting with YouTube, the player reporting milestones to the Google tag, and GA4 receiving video events.
Configure and test the player
In the GA4 interface, open Admin, then Data streams, and select the web stream. Confirm that Enhanced measurement is enabled. Open its settings and make sure the video engagement option is enabled.
Use Tag Assistant preview or enable debug mode while testing. Then open the page, start the video, move through the required milestones, and watch DebugView. Search for video_start, video_progress, and video_complete. Select an event to inspect its parameters.
gtag('config', 'G-XXXXXXXXXX', { debug_mode: true });Replace the measurement ID with your own. Debug mode affects the test data sent by that tag configuration. It does not repair a player that does not support the YouTube JavaScript API.
Common failure modes
The events may be missing when:
- The iframe URL does not contain
enablejsapi=1. - The video is loaded by a custom player, Vimeo, or a native HTML
<video>element. - A consent-management system prevents the Google tag or YouTube player from loading.
- The page contains a duplicate GA4 tag, causing duplicate events.
- A single-page application replaces the player without properly loading or exposing the new iframe.
- The player is blocked by browser restrictions, an extension, or network policy.
If events appear twice, inspect the page source and Google Tag Manager for both automatic enhanced measurement and a custom video tag. Disable one collection path before creating reports.
When you need different milestones, events for another video provider, or business-specific data such as course ID, use a custom event implementation instead of modifying the built-in event names.
Exercise
A YouTube iframe plays correctly, but no video_start event appears in DebugView. What should you check first?
Show answer
Confirm that the iframe URL includes enablejsapi=1, that enhanced measurement video engagement is enabled for the correct web stream, and that the Google tag is active in the test session.