Optimize
4.8K members online now
4.8K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me
star_border
Reply

Embeding JS code On Google Optomize version

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I want to embed JS code on BODY tag on one of the versions,

 

How can I do it ?

1 Expert replyverified_user

Embeding JS code On Google Optomize version

Google Employee
# 2
Google Employee

Hi,

 

You may select the <body> element (one easy way is by using the hierarchy bar at the top) and then select the "Run javascript" option either by the "EDIT ELEMENT" menu in the editor palette or by the right click popup menu.

 

Keep in mind that this code will not actually run synchronously (i.e. in the same way as if you had an inline script) but the Optimize runtime will guarantee that it will run after the selected element is available in the DOM.

 

Optimize Javascript changes also support the option of running that code after the starting tag (guarantee that only the element itself is in the DOM) or after the closing tag (the element and its contents are in the DOM).