reed/turbolinks-compatibility

Optimizely

jonathanng opened this issue · 2 comments

Anyone else having problems with Optimizely and Turbolinks?

Yup. And this post is the only thing on the interweb about it.

I seemed to have fixed the issue or at least a similar issue. I was having issues with optimizely not working with turbolinks so I added the script tag in the head and then in another js file I added a page:change and manually activated the experiments.

$(document).on "page:change", -> window.optimizely = window.optimizely or [] window.optimizely.push ["activate"]

With this you have to go into your settings on optimizely and change the activation method to manual.
The code above will start all but you can trigger a specific one by doing:

$(document).on "page:change", -> window.optimizely = window.optimizely or [] window.optimizely.push ["activate", EXPERIMENT_ID]

Hopefully this is helpful.