Optimize
2.5K members online now
2.5K 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
star_border
Reply

Programmatically show/hide Google Optimize experiments

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi, I was wondering if it's possible to show/hide Google Optimize experiments programmatically from my front-end code.

 

EDIT [December 2, 2016]

I mean if it's possible to do the front-end modifications (DOM) on my end (for example: change button color, text) instead of relying on the Google Optimize javascript library.

As I'm working on a Single Page Application, it's not possible to rely on Google Optimize js lib for changes in the DOM. It would be awesome if I can get the variation ID that Google Optimize assigns to the user and depending on that, do the DOM manipulations in my front-end.

I have used Optimizely in the past and it allows you to do that.

 

Does anyone have experience with this? Is it even possible with the current version of Google Optimize?

 

2 Expert replyverified_user

Programmatically show/hide Google Optimize experiments

Top Contributor
# 2
Top Contributor

Hi @Agustin H you could probably choose to load or not to load optimize based on a set condition. 

 

Kind regards,

Zorin

Web analyst @ escapestudio.net

Programmatically show/hide Google Optimize experiments

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi @Zorin Escape, sorry for not explaining enough in my question ...

I meant if it's possible to do the front-end modifications on my end (for example: change button color, text) instead of relying on the Google Optimize javascript library.

As I'm working on Single Page Application, it's not possible to rely on Google Optimize js lib for changes in the DOM. It would be awesome if I can get the variation ID that Google Optimize assigns to the user and depending on that, do the DOM manipulations in my front-end.

I have used Optimizely in the past and it allows you to do that.

 

Does anyone have experience with this? Is it even possible with the current version of Google Optimize?

 

Programmatically show/hide Google Optimize experiments

Top Contributor
# 4
Top Contributor

Hi @Agustin H - try using a redirect type test - regardless if it is a question of a SPA and use anchors or similar in order to define what needs to be served in frontend.

 

For instance a redirect type test:

url 1 - myurl.com/#!/

url 2 - myurl.com/#!/var1

url 3 - myurl.com/#!/var2

 

I am sure you can create based rendering rules (js/css) based on URI params or some expected string.

 

Hope it helps.

 

Kind regards,

Zorin 

Web analyst @ escapestudio.net

Programmatically show/hide Google Optimize experiments

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Thanks, I'll try that.

Programmatically show/hide Google Optimize experiments

Top Contributor
# 6
Top Contributor

Forgot to mention - there is currently an issue with the Optimize redirect tests:

1. the page hiding snippet only works with A/B and MVT type tests - in case of redirect test you should hide the initial load in a custom way

2. be sure to block the initial GA pageview on myurl.com/#!/ as after the redirect you will have double count

 

If you need help just let me know. 

 

Kind regards,

Zorin

Web analyst @ escapestudio.net
Marked as Best Answer.
Solution
Accepted by Jason O (Community Manager)
December 2016

Programmatically show/hide Google Optimize experiments

Google Employee
# 7
Google Employee

An idea would be to do add a single "Run Javascript" change in your variation that just sets a global window variable.

Then your app could just check that variable to decide if it should do your custom front-end modifications.