AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

2.8K members online now
2.8K members online now
Everything you need to know about setting up Optimize including creating your account and container, linking to Google Analytics and how to tag your site.
Guide Me

Ensuring that on-page JavaScript executes after Google Optimize JavaScript changes

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have set up an A/B test where the top section of a page is replaced. In the replacement section (version B) there is a video link that should lightbox. However, my JS seems to run before the DOM is updated, and so misses the initialization of the link.

I've tried triggering the initialization of my javascript with JS inserted by Optimize, but this seems to execute too early as well. Is there an event I can listen for that indicates when Optimize is fully loaded?

I'd think this would be a common issue.