Skip to main content
Level 2
September 9, 2026
Solved

Unable to track more than 1 video on one page

  • September 9, 2026
  • 3 replies
  • 137 views

 

 

I am trying to track videos on a webpage. if webpage has 1 video, its getting tracked, but more than 1 video, when i am clicking on 2nd video. Its not getting tracked.

Scenario : When i click on 1st video, its tracked, but 2nd video is not tracked. when i refresh and click on 2nd video. Its tracked  but now 2st is not tracked. (Whichever video i click first gets tracked)

 

 


This is the rule for youtube playback enable tracking. I searched on AI tools and it suspecting that problem is in this rule only

for 2nd video...you tube start is not happening even though all seems correct

Note : The above code is for pageload irc frame in events

    Best answer by Jennifer_Dungan

    Part of the issue here is that the code you are using to pull out the “youtube” video will only ever find the first video on the page…  

    document.querySelector finds the first match and stops.


    I am not using any of the YouTube or other video plugins, I never successfully got them to work consistently… but on our site, I worked with our developers to have unique identifiers for each video, provide a data layer with details about all the videos on the page (using the unique id of each video placement), and create custom JS events for video actions (which along with details about the action, pass the unique identifier).

     

    This way, I can track each video placement properly and in isolation of one another… 

    3 replies

    Jennifer_Dungan
    Adobe Champion and Community Advisor
    Jennifer_DunganAdobe Champion and Community AdvisorAccepted solution
    Adobe Champion and Community Advisor
    September 9, 2026

    Part of the issue here is that the code you are using to pull out the “youtube” video will only ever find the first video on the page…  

    document.querySelector finds the first match and stops.


    I am not using any of the YouTube or other video plugins, I never successfully got them to work consistently… but on our site, I worked with our developers to have unique identifiers for each video, provide a data layer with details about all the videos on the page (using the unique id of each video placement), and create custom JS events for video actions (which along with details about the action, pass the unique identifier).

     

    This way, I can track each video placement properly and in isolation of one another… 

    Shubh28Author
    Level 2
    September 15, 2026

    Thank you for the explanation ​@Jennifer_Dungan !

    Jennifer_Dungan
    Adobe Champion and Community Advisor
    Adobe Champion and Community Advisor
    September 15, 2026

    I hope this helped. My solution requires more effort from both the developers and on my side to stitch “video data layers” to “video events”.

     

    You could try to modify your code to use querySelectorAll? 

     

    This should get all your YouTube iframes and not all the “play” buttons… however, I don’t know if the code will get confused between the players and track the wrong video interactions… you can only test that scenario and see what happens… try testing each video, try starting one video and then the second one… what happens when two or more are playing at once?