---
title: JavaScript API
slug: web-experimentation/api
docTags: 
createdAt: 2026-08-05T20:56:13.000Z
---

## Products

- Optimizely Web Experimentation
- Optimizely Performance Edge
- Optimizely Personalization

The Optimizely Web Experimentation 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 API functions can be grouped into the following three types:

- Functions that have a global effect on Web Experimentation and Optimizely Personalization execution.
- Function that can be used to develop experiences (see also [JavaScript execution](docId\:HoJnwtgtXMShSgBQKcLw0)).
- Function that can be used to monitor what Optimizely is doing.

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

:::hint{type="info"}
**Note**
Often, you need experiment or campaign IDs when troubleshooting with the JavaScript API. See [Find IDs for API calls](docId\:uu6zmA5Bkeqsq84hqUmL3). If you cannot find what you are looking for in the JavaScript API, see the [Optimizely Experimentation log](docId\:w2Y5Xt-a2k2tQC7tO6vd-).
:::

## Check the JavaScript API

1. [Open the developer console](docId\:syV6dWrXTf5oJQp5lBQ67).
2. Paste the API calls into the console.

:::hint{type="info"}
**Note**
Unlike Web Experimentation and Optimizely Personalization, whose JavaScript API is exposed with `window.optimizely`, Performance Edge uses `window.optimizelyEdge`. See the [Optimizely Performance Edge JavaScript API](docId\:TfvPNeoGUz2FBeBvp0YDF).
:::

## 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.

See the [Push](docId:86-DSaR8IxuKOgcISwm_-) and [Get](docId\:f6yVHA1pGrQ6APkpc_3hA) sections for documentation on all of the API functions.
