Skip to content

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.

Variation Code

The variation code itself activates the the feature. This is added in the Optimizely Dashboard.

  1. first edit your experiment
  2. then select a variation and click < edit:code > tab on the bottom right
  3. 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.

evaluate=force

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

Manually Activating a Variation/Feature

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.

Example Execution Flow

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"]);