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

Optimize
2.4K members online now
2.4K members online now
Discover how to select who is eligible to be in your experiment, and when they’re served experiment variations.
Guide Me
star_border
Reply

How to implement the Javascript variable Targeting rule in Google Optimize Experiment?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am trying to setup the google optimize for multiple websites. I am having different designs (templates) for different websites and I am having the javascript variable on my website which is having the value of template/design. There is no problem when I implement using URLs rule, but I want to implement it by Javascript variable.

 

Facing some hurdles as:

my javascript variable is template_id ( in my js file), that variable is available before the google analytics tracking code., created variables by the same name in Google Optimize with equals condition. Doesn't work. (what is that Global Variable Name in Google Optimize?)

 

This Article says Apply AND on what ( i don't want to apply more than one condition, also that says data layer variable need to be created?

 

Please provide some directions.

1 Expert replyverified_user

How to implement the Javascript variable Targeting rule in Google Optimize Experiment?

Google Employee
# 2
Google Employee

Hi

 

You should be able to achieve what you describe easily.

 

Ignore the "data layer variable" targeting section in the article - this is a different type of variable that is useful for users of the Google Tag Manager product.

 

Optimize requires to always have a URL or Path targeting rule, but this is just in order to help users avoid mistakes for the most common use cases.

 

You can just use a rule like "URL regex  .*" or "URL starts with <your domain>" and target all pages of your site.

 

Then the additional javascript based rule that you can AND, will actually control who will see the experiment.