The YouTube Video trigger is used to fire tags based on interactions with embedded YouTube videos on web pages.
With each interaction, data about the video and playback status is pushed to the data layer. Before you work with this trigger configuration, enable built-in video variables for data that you would like to capture.
To create a new YouTube Video trigger:
- Click Triggers New.
- Click Trigger Configuration and choose the YouTube Video trigger type.
- Configure the trigger:
- Capture options
- Start: Fires an event when the video begins to play.
- Complete: Fires when the video finishes.
- 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.
Percentage and time thresholds will only fire the trigger the first time they are reached. If the user seeks past a particular percentage or time threshold in the video, the event will not fire. - Advanced
- Add JavaScript API support to all YouTube videos: Check this box to enable the YouTube iFrame Player API. This ensures that the
enablejsapi
parameter is appended to YouTube video player URLs with an assigned value of 1. This enables the player to be controlled via iFrame or JavaScript. Note: This will cause the video to reload if it plays when Tag Manager loads. - Enable this trigger on: Select the appropriate 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.
Note: Because the scroll depth trigger attempts to calculate the dimensions of a page when it is loaded, it is best to wait until the window has fully loaded before this trigger is enabled. For best results Window Load (gtm.load) is the recommended option. - Add JavaScript API support to all YouTube videos: Check this box to enable the YouTube iFrame Player API. This ensures that the
- Capture options
YouTube Video triggers will work both on and after page load, so long as at least one of these items is present when Tag Manager loads:
- An embedded YouTube video.
- The YouTube IFrame API
<script>
.