Skip to content

Instantly share code, notes, and snippets.

Created Sep 18, 2017
What would you like to do?
from optimizely import optimizely
# Initialize an Optimizely client
optimizely_client = optimizely.Optimizely(datafile)
# Activate user in an experiment
variation = optimizely_client.activate('my_experiment', user_id)
if variation == 'control':
# Execute code for variation A
elif variation == 'treatment':
# Execute code for variation B
# Execute default code
# Track conversion event
optimizely_client.track('my_conversion', user_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment