Rich-text Reply

Forcing a variation without using URL params

manyu 01-22-15

Forcing a variation without using URL params

Hi,

Is there any way to force a variation without using URL params?
Like through a javascript function or variable?

Level 1

Joel_Balmer 01-22-15
 

Re: Forcing a variation without using URL params

Hi there!

 

Yes, you could take advantage of our API call to bucketVisitor, here.

 

After this you could refresh the page (redirect to the same page). The code would look something like this:

 

window['optimizely'] = window['optimizely'] || [];
window['optimizely'].push(["bucketVisitor", experiment_id, variation_id]);
var currentLocation = window.location.href;
window.location.href = currentLocation;

 

I hope that helps you!