Getting started with Optimizely's JS API
1. Create an Optimizely account
If you don't have an Optimizely account already, just sign up for a free developer account. This account will give you access to core Optimizely features and API access, but with limited traffic allocation. No credit card is required, but you can always upgrade your account to a paid plan later.
2. Implement the Optimizely Snippet
If you are not already running Optimizely, you'll need to add the Optimizely Snippet to the head section of your web page. See Implementing the Optimizely Snippet for detailed instructions on how to add the Optimizely Snippet for your project.
3. Start an experiment
4. Read from the Data Object
The Optimizely Data Object is a read-only data object that contains information about the current visitor. You can use the Data Object to retrieve the state of and details about Optimizely experiments, variations, and goals for that visitor. For example, you can read which experiments and variations a visitor has seen and pass this information to your internal database.
To access the Data Object, open your browser console and type
For example, you can see what experiments are active for the current visitor in the object below:
5. Make an API call
In addition to reading from the Data Object, you can also make API calls to write data and modify the behavior of Optimizely. The API function calls expose many of Optimizely's decisions and actions so you can take control.