The JavaScript API in Optimizely Web Experimentation and Optimizely Performance Edge

  • Updated

Relevant products:

  • Optimizely Web Experimentation
  • Optimizely Performance Edge

This topic describes how to:
  • Find out what experiments or campaigns are active on a page
  • Check whether the snippet has updated to include the latest revisions
  • Check which variation a visitor is bucketed into

The Optimizely Web Experimentation and Optimizely Performance Edge JavaScript API gives you access to data saved in your projects. It contains optimizely.push and optimizely.get functions that let you see what's in your experiments and campaigns.

The JavaScript API is a simpler way to check: 

  • Which experiments and campaigns are active on the current page

  • Which variation you're bucketed into

This article provides a shortlist of the most common API calls and shows you how to use them.

Often, you'll need experiment or campaign IDs when troubleshooting with the JavaScript API. Here's how to find them under API Names.

If you can't find what you're looking for in the JavaScript API, you can also use the Optimizely Experimentation log.

Check the JavaScript API

  1. Open the developer console.

  2. Paste the API calls into the console. Below, we provide a list of the most common API calls for troubleshooting.

Unlike Optimizely Web Experimentation, whose JavaScript API is exposed via window.optimizely, Optimizely Performance Edge uses window.optimizelyEdge. See the Optimizely Performance Edge API Reference.

For a complete list, see our developer documentation.

Common API calls


Returns an array of active experiment IDs on a page.

In Optimizely Web Personalization, there are multiple experiments within a single campaign. But in Optimizely Web Experimentation, there is only one experiment for each campaign.


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.


Returns an object containing the mapping of all experiment variations a user has been bucketed into in its lifetime.

The experiment IDs are the object keys. The object contains the corresponding variation a user has been 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 all the Pages that are active on the URL you are on.