HTML5 Video Lightbox & Google Analytics (GA4)

I am currently setting up HTML5 Video Tracking in GTM and GA4. I am working to modify the script on the linked page to also react to videos loaded in through the “Link to: Video Lightbox” feature inside Bricks Builder.

I have two questions:

  1. Is a querySelectorAll(‘a[data-pswp-video-url]’) a reliable way to check whether lightbox videos are present?
  2. Is there any event I can listen to to track new videos being opened inside PhotoSwipe lightboxes?

The issue with the method outlined in the article I linked to is that it only works for <video> tags present on the page on load. PSWP and Bricks Builder load in the videos on demand, so I need to account for that.

Any pointers appreciated.

Thanks