Limited-time sale on all Analytics Mania's courses!

Learn more
  • Courses
    • 🔥 SALE 🔥
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • 🔥 SALE 🔥
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

March 1, 2025

Youtube trigger isn’t working in Google Tag Manager? 9 ways to fix it

Updated: March 31st, 2025

This is an updated version of the blog post posted in 2016 (when the built-in YouTube trigger was not in GTM yet).

In the autumn of 2017, the Google Tag Manager team released multiple awesome features, and the native YouTube trigger was one of them. Before that happened, the industry utilized custom video tracking solutions created by Bounteous or Cardinal Path.

Even though the new YouTube trigger was a great addition to the feature set within GTM, it wasn’t (and still isn’t) bulletproof. Due to certain factors (I’ll explain them later), it will not be able to track some YT players. That’s why you occasionally see new posts in GTM communities or forums asking for help tracking YT videos.

In this blog post, I’ll share several tips/workarounds you can implement to track videos when the Youtube trigger isn’t working in Google Tag Manager.

Here’s what you will learn in this article:

  • The result you should expect from the built-in YouTube trigger in GTM
  • Why is the built-in YouTube trigger not working in Google Tag Manager?
  • How to fix the YouTube trigger in Google Tag Manager? (+ some alternatives)
    • #1. Enable JavaScript API support
    • #2. Play around with the new “Enable this trigger on” setting
    • #3. Load the YouTube Iframe API library
    • #4. Privacy-enhanced mode
    • #5. Check if the embedded YouTube video contains the “src” attribute
    • #6. When the src attribute is updated later
    • #7. Embedded YouTube video’s URL must contain valid query parameters
  • Other solutions (replacements of the built-in YouTube trigger in GTM)
    • #8. Custom YouTube listener by Bounteous
    • #9. Modified Cardinal Path’s solution
    • Bonus: Changed video URL
  • Conclusion

 

The result you should expect from the built-in YouTube trigger in GTM

Here’s how YouTube video tracking should work in the perfect scenario:

  1. You must have at least one YouTube video trigger enabled on a page
  2. When you interact with the embedded YouTube video player, a YouTube video event appears in the Preview and Debug console (that’s because the YouTube auto-event listener catches the interaction and pushes it to the Data Layer).
  3. If this happens, you’re good to go. Enable the built-in video variables in GTM, create a tag (e.g., GA4 Event), and fire it on those YouTube video data layer events.

However, this does not always happen. The main problem with the YouTube trigger in GTM is that the YouTube video does not appear with all videos. Why?

 

Why is the built-in YouTube trigger not working in Google Tag Manager?

The leading cause of this problem is a thing called lazy-loaded videos. For example, suppose a video player is not loaded with the entire page document but later (e.g., in a popup after a user clicks a big blue button on your homepage). In that case, Google Tag Manager considers it a lazy-loaded video, and the built-in GTM trigger will not track its interactions.

Another popular reason for the YouTube trigger not working is the absence of the enablejsapi query parameter in the embedded YouTube video player code. When this parameter is set to 1, the website (and GTM, of course) can start listening to the player via JavaScript API.

Other possible reasons are that the embedded YouTube video uses privacy-enhanced mode or has a query parameter origin set to null. So, let’s take a closer look at them and what are the possible solutions.

Google Tag Manager Ebook Bundle

How to fix the YouTube trigger in Google Tag Manager? (+ some alternatives)

 

Option #1. Enable JavaScript API support

The first thing you could do with the trigger if you do not see YouTube video events in the Preview and Debug console is to enable JavaScript API support. How can you do that? You have two options:

#1.1 Ask a developer (or change it yourself if you have access to the website’s code) to add an additional query parameter enablejsapi=1 to the URL of the embedded YouTube video. Before you do that, you need to make sure that this is a problem at all. Inspect the video player and look for the iframe element that loads the YT video. Check its src attribute. Does the URL contain enablejsapi=1? If not, you could ask a developer to add this parameter to the embedded video’s URL.

#1.2. Or use the checkbox in the trigger’s settings: Add JavaScript API support to all Youtube videos. After you enable this checkbox, Google Tag Manager will check the existing embedded YT videos on a page. If some of them are missing this query parameter, it will be added automatically.

The main advantage of the second solution is that it does not require a developer’s input. But on the other hand, it will add a flicker effect to the player. This means that GTM will reload the player once to load it with the enablejsapi query parameter present. This can become an issue if a video on your page starts playing automatically (because it might start playing, then GTM will reload it, and it will start playing again). This is a VERY rare edge case (but still worth knowing).

Important: If the embedded YT video is already using the enablejsapi parameter that is set to 0 (enablejsapi=0), then GTM will not change its value to 1. Unfortunately, that’s how GTM works now (thanks to Simo Ahava for his comment).

Important #2: You must add enablejsapi to the URL as a valid query parameter. This means that it must go after the question mark, and if there are multiple query parameters, then they should be connected with an ampersand &.

Good example: https://www.youtube.com/embed/93ba93bas?feature=oembed&enablejsapi=1

Bad example: https://www.youtube.com/embed/93ba93bas?feature=oembed&enablejsapi=1

Also, if there is no ampersand in front of the enablejsapi (when it should be), that’s also not good.

If you are dealing with incorrect ampersands (e.g., encoded &), you must ask your developer for a fix.

Also, another important note from Simo was that if the embedded player’s URL contains the query parameter origin set to null (origin=null), the Youtube trigger will also not work. Ask a developer to remove that parameter from the URL (or it should contain the domain URL that the player is embedded on).

 

Option #2. Play around with the new “Enable this trigger on” setting

Google Tag Manager YouTube trigger lets you control when the tracking functionality is activated on a page:

  • At the earliest moment when the GTM container loads (gtm.js event)
  • When the Document Object Model is ready, a.k.a. DOM Ready (gtm.dom event)
  • When all scripts are loaded on a page, a.k.a. Window Loaded (gtm.load event)

By default, YouTube Trigger is enabled on the DOM Ready event. However, you may try to delay it and enable it on Window Loaded. That may help if the video is injected dynamically into the page, and that happens after the DOM-ready event has already occurred.

 

Option #3. Load the YouTube Iframe API library

In addition to the enablejsapi=1 requirement, there are two more things you need to keep in mind to make the YouTube listener start working. The built-in YT trigger will work if the condition meets at least one of these two things:

  • An embedded video must already be present on a page when the GTM container loads
  • Or the YouTube Iframe API script must be present on a page when the GTM container loads

So if one of these two things is on a page, the YT listener will be activated and start listening to video interactions.

However, as I mentioned at the beginning of this blog post, the main problem comes with the lazy-loaded videos. When GTM loads, the lazily loaded video (and the YouTube Iframe API script) are absent; therefore, the listener never activates.

A solution? Load the YouTube API script before the YouTube Trigger is enabled. Create a Custom HTML tag with the following code:

<script src="https://www.youtube.com/iframe_api">

And fire it on All Pages (or only those pages where the lazy-loaded YouTube video can appear). Just make sure you choose the Page view trigger.

Then enable the YouTube trigger on the DOM Ready event. Or if you have set the Custom HTML tag to fire on DOM Ready, then set the YT trigger to be enabled on Window Loaded event.

I have yet to use both of them on the same event, but I presume there might be some rare conditions (I might be wrong there, so feel free to correct me).

And that’s it! When the page loads, the YouTube API script is already available; thus, the YouTube trigger will be activated and listen to video interactions. As a result, you should start seeing YouTube video events in the Preview and Debug console.

However, other factors may still be interfering with your YT tracking (e.g., enablejsapi parameter is set to “0” or is missing at all), so make sure you’ve read other tips here as well.

This is not a silver bullet (but still a handy tip). I just love the GTM community and constant learning!

 

Option #4. Privacy-enhanced mode

YouTube video players can also be embedded with the privacy-enhanced mode (that does not store cookies on the visitor’s browser). However, if this setting is enabled, the YouTube trigger will not work (because, in this case, the video will be loaded not from youtube.com but from youtube-nocookie.com instead).

How can you know whether the embedded video player is in privacy-enhanced mode?

Inspect the player and check with the iframe’s source (see the src attribute). If the domain is youtube-nocookie.com, that’s the privacy-enhanced mode.

What options do you have?

  • Disable the privacy-enhanced mode by changing the youtube-nocookie.com to youtube.com in the code of the embedded player (this needs to be done in the website’s source code or the content management system’s editor. However, in light of GDPR, this might not be the best option.
  • Accept the defeat and skip YouTube tracking.
  • Use a custom listener and modify its code to start listening to youtube-nocookie.com instead of youtube.com. If, for example, you want to start using solution #9 (from this blog post), replace these two domains with the youtube-nocookie.com in that listener’s code (it is available in the Custom HTML tag).

 

Option #5. Check if the embedded YouTube video contains the “src” attribute

Sometimes YouTube videos are embedded in a non-standard way. By saying “non-standard”, I mean that the embedded video’s src attribute (that contains the video’s URL) does not exist.

Instead, developers use the data-src attribute.

To ensure you’re dealing with this issue, inspect the video player, locate the iframe element, and check whether the src attribute (see the screenshot below) contains the www.youtube.com URL.

If not, then the YouTube video tracking will not work.

In the screenshot below, the iFrame element has the src attribute, but it contains the image, not the video URL. Instead, the video URL is stored in the data-src attribute.

What is the solution? Ask a developer to fix this issue and store the video URL in the src attribute. That’s the only solution.

 

Option #6. When the src attribute is updated later

This option might look a bit misleading or confusing, but bear with me. In fact, it is related to option #5. When developers want to optimize the page loading speed, one of the places that definitely can improve things is lazy-loaded YouTube video players.

For example, only the thumbnail is displayed when a player is on a page. When the visitor clicks the play button, the player is loaded, and you watch the video.

Unfortunately, this is not often supported by the built-in YouTube trigger in Google Tag Manager.

Here is a situation: when the page is loaded, click Inspect Element on the player. If that inspected element contains the data-src attribute (that contains the URL of the video) BUT:

  • The src does not exist in that very same element
  • OR the src exists but its value is not https://www.youtube.com/embed/oasbsaoasd….., then continue reading this tip.

Now, check another thing. While inspecting that element, click the video thumbnail/play button. Did the src attribute of the player get a new value, which is the URL of the video + additional parameters (like enablejsapi=1)?

If this is exactly what you see in your project, here’s why the Youtube trigger does not work. One of the things that this trigger is looking for is iframe elements that contain the src attribute with the URL of a Youtube video. This check happens when the GTM container is loaded (but it depends on the settings).

During the initial page load, your YouTube players do not contain the “src” attribute with the YouTube URL (because the URL is stored in the data-src attribute). When GTM loads, the YouTube listener checks all the YouTube players on a page and inspects them once. When the element is inspected, it gets a new attribute called data-gtm-yt-inspected….

Even if the YouTube player’s URL (in the src attribute) changes, that change will not be noticed by GTM anymore (because the player was already inspected, and it got that data-gtm-yt-inspected… attribute.

How can you solve this? You’ll need the developer’s input.

Your developer must make specific code changes responsible for the lazy loading of the video. The developer will have to figure this out.

When a visitor clicks on the video thumbnail, the src attribute is updated with the actual YouTube URL. To make sure that the GTM YouTube listener notices this, ask a developer also to add some functionality that removes all the data-gtm-yt-inspected… attributes that were added. This must be done every time a visitor clicks the thumbnail, and the actual video player is loaded.

This will force GTM to recheck the player and start tracking it.

Keep in mind that in your case, the number of data-gtm-yt-inspected… attributes and their names will, most likely, be different.

 

Option #7. Embedded YouTube video’s URL must contain valid query parameters

When I say “valid” query parameters, they must come after a question mark (in the URL). Multiple parameters must be connected with an ampersand (&).

This is a correct example of the URL (that you can see if you do the “Inspect element” on the embedded YouTube player):

But in some rare cases, you might see something like this:

Every URL parameter is connected with &amp; instead of just &. This breaks the YouTube video player tracking in GTM. The solution here is to ask a developer to identify the code on a site that is causing this and fix it.

 

Other solutions (replacements of the built-in YouTube trigger in GTM)

Even though the aforementioned tips should be enough to fix the Youtube Trigger in Google Tag Manager, you might also find useful two tips mentioned below. They are both custom (in fact, that’s how the web tracking industry was rolling back in the older days of YouTube tracking).

 

Option #8. Custom YouTube listener by Bounteous

Before GTM offered the built-in YouTube trigger, people used either Bounteous’s or Cardinal Path’s custom solutions. Bounteous’s listener supports lazy-loaded videos (at least in most cases that I remember). So if, for some reason, none of the above tips helped (even though that’s very unlikely), you can try implementing this one.

Just remember that this custom solution uses custom triggers and variables (meaning you’ll need to create Data Layer Variables and Custom Event trigger on your own. The built-in video triggers will not work here.

 

Option #9. Modified Cardinal Path’s solution

Cardinal Path created another custom solution that was popular in the industry. However, I remember working on one project where neither Bounteous’ nor this Cardinal Path’s solution worked.

As a result, I asked a colleague of mine who is a JavaScript developer to modify the listener a bit. Now that the listener is listening to changes in the YouTube player every second. So even if the video is lazily loaded, after 1 second, it will be tracked. Here’s the listener’s code:

<script>
        //enable the JavaScript API for an embedded player
        for (var e = document.getElementsByTagName("iframe"), x = e.length; x--;)
                if (/youtube.com\/embed/.test(e[x].src))
                        if (e[x].src.indexOf('enablejsapi=') === -1)
                                e[x].src += (e[x].src.indexOf('?') === -1 ? '?' : '&') + 'enablejsapi=1';

var gtmYTListeners = [],
        gtmYTListenersStates = []; // support multiple players on the same page
// attach our YT listener once the API is loaded
function onYouTubeIframeAPIReady()
{
        for (var e = document.getElementsByTagName("iframe"), x = e.length; x--;)
        {
                if (/youtube.com\/embed/.test(e[x].src))
                {
                        gtmYTListeners.push(new YT.Player(e[x],
                        {
                                events:
                                {
                                        onError: onPlayerError,
                                        onReady: onPlayerReady
                                        //onStateChange: onPlayerStateChange
                                }
                         }));
                         YT.gtmLastAction = "p";
                }
        }
}

function onPlayerReady(e)
{
         var url = e.target.getVideoUrl();
         gtmYTListenersStates[url] = e.target.getPlayerState();

         setInterval(function ()
         {
                  var state = e.target.getPlayerState();

                  if (gtmYTListenersStates[url] !== state)
                  {
                          e.data = state;
                          onPlayerStateChange(e);
                   }
                   gtmYTListenersStates[url] = state;
           }, 100);
}

// listen for play, pause and end states
// also report % played every second
function onPlayerStateChange(e)
{
         e["data"] == YT.PlayerState.PLAYING && setTimeout(onPlayerPercent, 1000, e["target"]);
         var video_data = e.target["getVideoData"](),
                 label = video_data.title;
         // Get title of the current page
         var pageTitle = document.title;
         if (e["data"] == YT.PlayerState.PLAYING && YT.gtmLastAction == "p")
         {
                label = "Video Played - " + video_data.title;
                dataLayer.push(
                {
                         'event': 'youtube',
                         'eventCategory': 'Youtube Videos',
                         'eventAction': pageTitle,
                         'eventLabel': label
                 });
                 YT.gtmLastAction = "";
           }
           if (e["data"] == YT.PlayerState.PAUSED)
           {
                    label = "Video Paused - " + video_data.title;
                    dataLayer.push(
                    {
                             'event': 'youtube',
                             'eventCategory': 'Youtube Videos',
                             'eventAction': pageTitle,
                             'eventLabel': label
                     });
                     YT.gtmLastAction = "p";
              }

}

// catch all to report errors through the GTM data layer
// once the error is exposed to GTM, it can be tracked in UA as an event!
function onPlayerError(e)
{
           dataLayer.push(
           {
                   'event': 'error',
                   'eventCategory': 'Youtube Videos',
                   'eventAction': 'GTM',
                   'eventLabel': "youtube:" + e["target"]["src"] + "-" + e["data"]
            })
}

// report the % played if it matches 0%, 25%, 50%, 75% or completed
function onPlayerPercent(e)
{
          console.log("onPlayerPercent");
          if (e["getPlayerState"]() == YT.PlayerState.PLAYING)
          {
                   var t = e["getDuration"]() - e["getCurrentTime"]() <= 1.5 ? 1 : (Math.floor(e["getCurrentTime"]() / e

                   ["getDuration"]() * 4) / 4).toFixed(2);
                   if (!e["lastP"] || t > e["lastP"])  
                   {
                            var video_data = e["getVideoData"](),
                                     label = video_data.title;
                            // Get title of the current page
                            var pageTitle = document.title;
                            e["lastP"] = t;
                            label = t * 100 + "% Video played - " + video_data.title;
                            dataLayer.push(
                            {
                                     'event': 'youtube',
                                     'eventCategory': 'Youtube Videos',
                                     'eventAction': pageTitle,
                                     'eventLabel': label
                            })
                     }
                     e["lastP"] != 1 && setTimeout(onPlayerPercent, 1000, e);
            }
}

// load the Youtube JS api and get going
var j = document.createElement("script"),
        f = document.getElementsByTagName("script")[0];
j.src = "//www.youtube.com/iframe_api";
j.async = true;
f.parentNode.insertBefore(j, f); 
</script>

It will push the “youtube” events to the Data Layer. Cardinal Path’s blog post explains everything if you must determine what variables and triggers you should create. All you need to do is update Cardinal Path’s Custom HTML tag’s code with the one I posted above.

The solution isn’t perfect (compared to those at the beginning of the post), and it can cause some video flickering, but if you are looking for a plan B, this might be it.

In this case, you should also remember that this solution uses custom triggers and variables (meaning that you’ll need to create Data Layer Variables and Custom Event trigger on your own. The built-in video triggers will not work here.

 

Bonus Option #10. Changed video URL

This is an edge case but still worth checking. So, recently I stumbled upon a case where none of the above-mentioned solutions worked (this happened in the #MeasureSlack). A video player appeared in a popup only after a visitor clicked a specific button on a page.

But there was something different that broke the player tracking.

The YouTube video player was always on a page but was hidden. When GTM loaded, the YouTube listener successfully spotted the video player and was ready to start listening. However, when the button was clicked (that opens a video popup), some custom JavaScript on a page changed the YouTube video URL (added parameter ?autoplay=1). This caused the iFrame to reload and create a new instance of the iFrame, which GTM no longer tracks.

GTM’s built-in YouTube tracking checks video players on a page only once; hence, that new instance is ignored.

Here are a bit more details. I opened the Elements inspector in my Chrome browser and quickly searched for /embed/ (because your embedded YouTube videos have that in the URL).

Here’s a screenshot of the embedded player’s URL while the popup is still invisible.

Memorize this. The URL contains the hostname, /embed/some_id, and two query parameters (enablejsapi and origin).

However, when I click the button that opens a popup with a YouTube video, its URL changes to this one:

A new query parameter is added to the URL, autoplay=1. This URL change caused the issue that the GTM YouTube tracking was not working. And this is not related ONLY to autoplay. There could have been any parameter or any other change. YouTube tracking would not have worked.

What’s the solution? You need to tell the developers not to change the video URL. Or have those parameters added to the YT video URL right from the beginning.

The cause of this issue was spotted (to no one’s surprise) by Simo Ahava.

 

What to do when the YouTube trigger isn’t working in Google Tag Manager

So there you have it. 9 ways to solve the puzzle when the built-in YouTube trigger isn’t working in Google Tag Manager. Here are the key takeaways:

  • The default YouTube trigger will properly track YT videos if:
    1. enablejsapi is added to the URL of the embedded YouTube video player and is set to 1 (you can check that by inspecting the iframe of the YouTube video and checking its src attribute).
    2. and one of these conditions is met:
      • The YouTube video player is already present on a page when the GTM container loads (and that’s why lazy-loaded videos are not tracked by default)
      • The YouTube Iframe API script is already present when the GTM container loads.

The enablejsapi issue can be solved by a developer (ask him/her to add this parameter to the iframe src) or by enabling Add JavaScript API support to all YouTube videos checkbox in your GTM trigger. However, if the video URL already contains the enablejsapi=0 (which means disabled), ask a developer to set it to 1 in the website’s source code.

As for those other two conditions (where at least one must be met), create a Custom HTML tag that contains the YouTube Iframe API script and fire it before the YouTube trigger is enabled.

<script src="https://www.youtube.com/iframe_api">

All Pages trigger assigned to that Custom HTML tag should do the trick.

If these settings do not work (even though they should), consider checking other tips:

  • Look at whether your embedded videos are using the privacy-enhanced Youtube mode
  • Try implementing custom Youtube listeners. These solutions are not very elegant (compared to the built-in functionality of GTM) but still might serve as a plan B.
  • Check whether the URL of the embedded YT player does not contain origin=null query parameter. If it does, it should be removed (or set to the domain of the parent page).

As always, the comments section is at your service. Did I miss anything? Let me know.

Julius Fedorovicius
In Google Tag Manager Tips
38 COMMENTS
Stephan Wilmas
  • Jan 18 2019
  • Reply

This is awesome. I had a similar problem where there was a video wrapper(with DIVI theme) on the youtube embed and Tag Manager could not detect the gtm.video event. This worked great.

    guillaume
    • Apr 16 2019
    • Reply

    Stephan Wilmas, which of the above method worked for you?
    I'm facing the same issue with the divi video module, I'm unable to track the views.

      Julius Fedorovicius
      • Apr 18 2019
      • Reply

      Hey, have you tried all the methods explained here?

Gabriel
  • Mar 7 2019
  • Reply

Your articel was a great help. Not only for trouble shooting but also to get a better understanding on the matter of youtube tracking.

Have a great day,
Gabriel

PS: You are the man :)

Peter
  • Apr 12 2019
  • Reply

This was a huge help, thank you! Tag manager is working perfectly with lazy loaded videos, but unfortunately only on desktop. I'm not sure why, but the Youtube tag isn't working on mobile with lazy loaded videos. Any chance you might have some insight into this? Thank you either way!

    Julius Fedorovicius
    • Apr 18 2019
    • Reply

    Haven't noticed that. Are all other tags (excluding Youtube) working on your mobile version?

Aneri Gandhi
  • May 24 2019
  • Reply

Hello,

The solution you provided for lazy-loading video works great. There is one slight problem. My YouTube Video plays in a lightbox. The Start and Pause events are tracked when the video is started for the first time. When I close the lightbox and lauch it to play the video again, it does not track the Start and Pause events again. Although, it tracks the Progress Events. Any thoughts on how to achieve this?

Regards,
Aneri

    Tony
    • Nov 14 2023
    • Reply

    Hi Aneri,
    I have to same issue right now. Did you manage to fix this?

Mohit
  • Jul 25 2019
  • Reply

I've tried all of your options except for last custom tag! My page is playing youtube video on Button Click in Modal Window, and youtube trigger is not firing somehow, but if I directly past the iframe code to page , not placing in modal container then it works. can you tell me whats wrong with it ?

    Jamie
    • Aug 22 2019
    • Reply

    Hey, did you figure this out? I've got the same issue

      Julius Fedorovicius
      • Aug 23 2019
      • Reply

      Can you both share links to your websites with a quick description on where/how to find that video

Claire Boardman
  • Aug 17 2019
  • Reply

I'm working with a Wix site and the YouTube videos are embedded in a Lightbox. I've tried all your fixes above (thank you for sharing!) but it's still not working and I wondered if anyone had any experience/solutions?

Killian
  • Sep 20 2019
  • Reply

Hi Julius,

The Cardinal Path blog post page no longer loads.. I am having trouble tracking YT videos that are in an iframe in a carousel. Your version of the Cardinal Path solution sounds like it might work. Any ideas?

Thanks :)

    Killian
    • Sep 20 2019
    • Reply

    I imported the recipe.. unfortunately it also did not work :( ....is there anything else I can try?

      Julius Fedorovicius
      • Sep 23 2019
      • Reply

      You can try sharing the link to the page with the YT player here and I will take a look.

Swapna Ramaka
  • Dec 6 2019
  • Reply

Hi Julius,

I am trying to track the video interaction on my client website. The videos are embedded in a popup.

Ex: Articles are loaded in carousal.. when i click on each article link, opens in popup and a video is embedded in the content.

Tried creating an event listener but its not working. Can you help me out.

Embedded videos are from YouTube and Vimeo

Thank you

Bartek
  • Dec 30 2019
  • Reply

Hi Julius.

I have another reason why YouTube trigger isn't working. I had JW Player Listener enabled, which blocked YouTube trigger.
When I turned off JW Player Listener, the YouTube trigger started working.

priya
  • Jan 18 2020
  • Reply

I am facing issue when i am trying to track the auto play video which is the banner of the page. can we track auto play video?

Amit Prasad
  • Apr 16 2020
  • Reply

Will this solution also work for Single Page Application (for youtube video tracking)??

    Julius
    • Apr 16 2020
    • Reply

    The best way to find out is to try :)

Giny
  • May 2 2020
  • Reply

Woww.. because of custom iframe, i got solution. now my videos are tracking & i'm getting report in analytics. Thank you so much. great help indeed. have tried many options but your article helped me..

Thank You

Norman
  • Aug 6 2020
  • Reply

I look up a lot of things at work and have never commented on anything before, but this was a great article and made my life easier - well done

Tom Mercik
  • Aug 20 2020
  • Reply

Greetings Julius!

About to start Module 7 but decided to loop back to Module 3 because so fair, tracking YT was the only aspect causing me trouble.

Before I try either/both the Bounteaous/Cardinal Path options (since nothing else works), I thought I'd share the embed code for the youtube in question:

Is "encrypted-media;" the source of my troubles?

OR is it the theme (X) that's causing the challenges? Theme X provides very limited info via "View page source" and "Inspect".

THX in advance,
Tom

    Julius
    • Aug 21 2020
    • Reply

    Hi, what is the URL of the page?

Tom Mercik
  • Sep 3 2020
  • Reply

Greetings Julius, sorry for tardy response, family matter.

Url is: https://dogfenceontario.ca/link-dog-fence-ontario-phone-app/

    Julius Fedorovicius
    • Sep 4 2020
    • Reply

    You have a mix of problems here. You need to solve:
    1. Implement method #4 (you can do that on your own via GTM)
    2. You need to talk to developers and make sure that they implement method #5

    ALL of these requirements must be met. And two of them must be solved by your developers.

Max Thomas
  • Oct 30 2020
  • Reply

Thank you for this extremely helpful post. For the particular site I'm dealing with, "loading the Youtube API script before the Youtube Trigger is enabled" was the solution. Thanks again!

Glynn
  • Dec 4 2020
  • Reply

Thanks, Option 3 solved it for me!

Ivan
  • Dec 11 2020
  • Reply

Julius, thank you for this, you saved me a lot of time :)
Add JavaScript API support to all Youtube videos solution worked like a charm. I have two unrelated questions though:

On the client site I manage, there was already a GTM container placed by another agency that handles their advertising, so I placed my own container alongside it. Is there a problem with that, besides maybe adding some time to page load?

Other question is related to the first GTM container which is placed incorrectly, both scripts within the head tag of the page. Is there a problem with that? From what I could see, my container wouldn't work when I placed it correctly (second script within the body), so I too had to place both scripts to head in order for it to work...

Thanks and keep up the great work :)

Katherine
  • Nov 5 2021
  • Reply

In regards to the note you made in Bonus Option #9 on the URL. - - If I have the developer remove the autoplay=1 parameter, will the youtube trigger in GTM work without an origin parameter? -- I am inspecting the source url and it contains the hostname, /embed/some_id, and only one query parameter (enablejsapi). I did not see origin in the URL and wondered if that would be an issue.

Brandie Green
  • Nov 12 2021
  • Reply

We are having trouble tracking videos on our new stonesmart site. I've tried to debug but no luck. Any ideas on what might be wrong?

Lucas Kostka
  • Jan 25 2022
  • Reply

Hey, recent finding of a (seemingly) undocumented JS behavior, moving iframes in the DOM through JS also reloads the iframe, thus eliminating listeners...

George
  • Sep 16 2022
  • Reply

Thank you this was helpful. I'm working on a Laravel/Vue Build and the GA4 Enhanced Tracking wasn't working for YT videos.

The fix was to add the YT iframe API in the head.blade. Excellent :)

Juan S
  • Jun 7 2023
  • Reply

Hey Julius,

Thanks so much for your content.

I get to see all tags in GTM preview mode, but nothing on the debug mode (ga4)

Also, I created custom dimensions for them, but nothing in explorations either.

Any idea what might be the problem? I am going nuts :)

Haidong
  • Jun 27 2023
  • Reply

I'm a youtuber, and I don't have a website, and I will be using google ads to market my videos, is it possible to use GA4 to track the conversion(subscription) and cpc from google display as or search ads?

    Julius Fedorovicius
    • Jun 27 2023
    • Reply

    no

      Haidong
      • Jun 27 2023
      • Reply

      thanks for your quick reply, is there any good practice for a youtuber like me, I know you have the youtube channel as well, is there any blog or videos of yours that you would recommend me to watch?

Caitlin
  • Jul 21 2025
  • Reply

I have a webpage with two videos on it, and the first one does not record any activity in GTM Preview Mode, whereas the second one appears to be working correctly. When inspecting, the code for both looks identical. I worked through options 1, 2, 4, 5, 6 and 7 with no success. I have a feeling options 3, 8 and 9 may not be relevant if I have one video on the page working and the other not working. Do you have any other troubleshooting tips or any suggestions for why only one video would track? This is the page: https://sed.visionaustralia.org/umekos-pack

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Conversion rate in Google Analytics 4
  • Google Tag Manager Data Layer Explained
  • Cross-domain tracking in Google Analytics 4
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings