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

Agata Jędrzejczyk
Written by Agata Jędrzejczyk

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 did 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 with 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 User Engagement section. You have a number of 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, and buffering when the video starts buffering due to lack of bandwidth.
  • Progress - track specific progress with percentage or timestamps in seconds. Input one or more positive integers in a coma-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 tag fires. 

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

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 choose your just set up YouTube trigger Tag. That will send this event to User.com.

Remember to previously create those event attributes inside your app, if the type of them is different than 'string'. To do this, go to: Settings > App settings > User data & events > Event attributes.

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

Related articles

Categories: