Search through more than a hundred articles on every aspect of User.com

Maciej Rzadkowski
Written by Maciej Rzadkowski

How to track YouTube videos via GTM

Create an event after starting a video on your page to trigger an action


Thanks to YouTube video Trigger in GTM, you can send an event based on the actions your users were taking while using YouTube.

Before you start

You need to have GTM implemented on your site. Find out how in here.

How to use it

You can create & configure the trigger in your GTM Workspace linked to your website.

1. Open your GTM Workspace connected to your website.

2. Go to Triggers and click the button New.

3. Choose Trigger Type: YouTube Video under the User Engagement section.

4. You have several options to pick from now:

Capture

  • Start - tracks a start when the user starts watching the video.
  • Complete - tracks a complete when the user reaches the end of the video.
  • Pause, Seeking, and Buffering - tracks a pause when the user pauses the video or jumps forward or back, also tracks buffering when the video starts buffering due to lack of bandwidth.
  • Progress - tracks specific progress with percentage or timestamps in seconds. Input one or more positive integers in a comma-separated list.

Advanced

  • Add JavaScript API support to all videos - The trigger will fire only on YouTube videos that have JS API support. Checking that will add the missing parameter to all YouTube videos on the page. Note: This will cause the video to reload if it is already playing when the tag fires. 

There are also Built-in Variables helpful here - go to Variables > Configure > Videos, and there you have them!

Choose Build-In Variable to see the list of available Variables.

These are Data Layer variables with their values:

To send an event triggered by this exact trigger, go to Tags > New > Tag configuration: Custom HTML, and under Triggering just choose your set-up YouTube trigger Tag. That will send this event to User.com.

If their type is different than 'string', remember to create these events attributes inside your app beforehand. To do this, go to: Settings > App settings > User data & events > Event attributes.

This is what you're going to see in the User's profile - event and its attributes:

Related articles

Categories: