Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting GTM's Youtube Trigger Failing to Fire Consistently

  • Troubleshooting GTM's Youtube Trigger Failing to Fire Consistently

    Posted by Jordan on 25 March 2023 at 1:13 am

    “Hey, I’m having a bit of trouble with YouTube event tracking in Google Tag Manager for Google Analytics 4. The built-in feature isn’t working for me, so I’ve been trying to do it manually. Here’s the weird thing, the tracking works perfectly for the first video I play when I test it in preview mode. But then, any other videos I click to play after that aren’t detected as YouTube events in preview mode – they’re just showing up as link clicks. So far, I’ve tried enabling the trigger ‘en container loaded’ (this is the only way I can get it to read at least the first clicked video) and I’ve also tried adding a Custom HTML that fires on all pages with the highest priority, as suggested by ‘analyticsmani’ (basically, the full HTML was “script src=”https://www.youtube.com/iframe_api”). But, I’d really like it if the event would fire with the event tag every time I click on a video, not just the first one. Oh, and this might be important: each video is inside of a modal that opens up when you click on a call to action like ‘Watch more’. So, I click on that, the modal opens, I click again and the video starts. Got any ideas why this is happening and how to fix it?”

    Addison replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Mia

    Member
    26 March 2023 at 6:58 am

    Sure, let’s unravel this a bit. Now, here’s where it gets interesting – when you’re managing to play the first YouTube video, it’s picking up the event and recognising it as a YouTube event – that’s great! But then, any videos after that just show up as link clicks, right?

    This could be happening because each time you go to play another video, you could be just changing the source or the video link in the YouTube element (this is known as the DOM, or Document Object Model) within your site – which might be wrapped inside that modal you mentioned.

    Google Tag Manager however, doesn’t track again when you change the source or video link, it just looks at the element or ‘container’ when it first loads on the page, and then any changes after that don’t register as YouTube events.

    What might be worth checking is whether each video in the modal is using the same YouTube DOM and only changing the URL. Because if that’s the case, GTM might be seeing it as one continuous link click rather than separate YouTube events. I know it’s a bit of a conundrum, but hopefully, this shines a light on what could be happening!

  • Addison

    Member
    1 April 2023 at 2:10 am

    It sounds like the issue you’re experiencing could be related to how Google Tag Manager (GTM) is interacting with the modal that your video lives in. Once the first video is played, GTM might not be recognizing the other videos as new components because they’re loaded dynamically within the same modal and, as a consequence, only the first video gets tracked. Try setting up ‘Observer Tags’ in GTM which is specifically designed to monitor changes in the elements of the page, like the loading of a new video in an existing modal. This tag can trigger whenever a new video gets loaded in the modal. Also, ensure that all your videos are appropriately tagged. Lastly, in your GA4 settings, make sure that ‘Enhanced measurement’ is turned ON and the specific video tracking feature is enabled under that setting. By trying this, the event should fire with the tag every time you click on a video, not just the first one.

Log in to reply.