Overview
This guide explains how to track YouTube video interactions (such as plays, pauses, and completions) on your website using Google Tag Manager (GTM), and send that data to HubSpot as Custom Behavioral Events.It is designed for marketing and operations teams that want to analyze video engagement and trigger automated workflows based on user behavior.
Prerequisites
- Before you begin, ensure the following are in place:HubSpot Enterprise subscription
(Marketing Hub or Operations Hub Enterprise is required for Custom Behavioral Events) - Google Tag Manager access with publish permissions
- YouTube videos embedded on your website
- HubSpot tracking code is installed on your siteIf your site is hosted on HubSpot, the tracking code is automatically included
- If external, you must add the HubSpot tracking code manually
Step 1: Prepare the YouTube Embed Code
The YouTube iframe must include the enablejsapi=1 parameter for GTM to detect video events.Correct Format:
Note: If you copied the embed code directly from YouTube, you will need to manually add &enablejsapi=1 to the video URL.
Step 2: Enable Built-In GTM Variables
In GTM, go to Variables > Configure
Under “Videos“, enable the following:
- Video Current Time
- Video Duration
- Video Percent
- Video Provider
- Video Status
- Video Title
- Video URL
Step 3: Create a YouTube Video Trigger
Go to Triggers > New
Choose YouTube Video as the trigger type
Configure the following:
- Capture: Start (add Pause or Complete as needed)
- Check: Add JavaScript API support to all YouTube videos
- Fire on: All Videos
- Name the trigger:
TRG - YouTube Video Start - Save the trigger
-
Step 4: Create the Custom HTML Tag for HubSpot