Integrating a Feature with Optimizely
Caleb Wright edited this page Nov 5, 2015
·
11 revisions
pinball allows easy integration optimizely. Note: Only features that are available can be activated.
The variation code itself activates the the feature. This is added in the Optimizely Dashboard.
- first edit your experiment
- then select a variation and click < edit:code > tab on the bottom right
- then adjust the variation specific code and save
/* _optimizely_evaluate=force */
window.pinball = window.pinball || [];
window.pinball.push(['activate','feature_name','optimizely']);
/* _optimizely_evaluate=safe */
The third parameter ('optimizely'
) helps to debug by letting users know it was activated from Optimizely.
From here, pinball
takes care of everything else.
To activate features immediately, use /* _optimizely_evaluate=force */
(as seen above). This instructs Optimizely to run the JavaScript immediately rather than waiting for DOMContentReady
. Further Reading
After Optimizely is setup, you can activate it through their API by appending to the URL: ?optimizely_x[EXPERIMENT_ID]=[VARIATION_ID]
You should see the feature.
javascript:
window.pinball = window.pinball || [];
window.pinball.push(['add', #{{PinballWizard::Registry.to_h.to_json}}]);
script src="//cdn.optimizely.com/js" type="text/javascript"
javascript:
window.optimizely = window.optimizely||[];
window.optimizely.push(["activate"]);