- Optimizely Web Experimentation
- Optimizely Performance Edge
- Optimizely Personalization
The Optimizely Web Experimentation, Optimizely Performance Edge, and Optimizely Personalization JavaScript API gives you access to data saved in your projects. It contains optimizely.push
and optimizely.get
functions that let you see what is in your experiments and campaigns.
The JavaScript API is a way to check:
- Which experiments and campaigns are active on the current page
- Which variation you are bucketed into
This article provides a short list of the most common API calls and shows you how to use them.
If you cannot find what you are looking for in the JavaScript API, see the Optimizely Experimentation log.
Check the JavaScript API
- Open the developer console.
- Paste the API calls into the console.
window.optimizely
, Optimizely Performance Edge uses window.optimizelyEdge
. See the Optimizely Performance Edge API Reference.Common API calls
-
optimizely.get('state').getActiveExperimentIds()
Returns an array of active experiment IDs on a page.
- In Optimizely Performance Edge, there are multiple experiments within a single campaign.
- In Optimizely Web Experimentation and Optimizely Personalization, there is only one experiment for each campaign.
-
optimizely.get('data').revision
Returns the revision that the snippet on the page is on. Useful in determining whether you are looking at the most updated changes made within a campaign.
-
optimizely.get('state').getVariationMap()
Returns an object containing the mapping of all experiment variations a user is bucketed into in its lifetime. The experiment IDs are the object keys. The object contains the corresponding variation a user is bucketed into for each experiment, where the "id" and "name" values correspond to the variation.
-
optimizely.get('state').getPageStates({"isActive": true});
Returns an object of the pages that are active on the URL you are on.
Please sign in to leave a comment.