Skip to main content

We are currently experiencing an issue that is preventing customers from submitting support tickets. Please contact us at (866) 819-4486 if you need immediate assistance.

Optimizely Knowledge Base

QA Optimizely X: Use the JS API, console log, and network panel

This article is about Optimizely X. If you're using Optimizely Classic, check this article out instead.
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization
  • Optimizely X Web Recommendations

  • QA and debug experiments using the JS API and Optimizely log
  • Check goal firing within the network panel

Optimizely X Web has a few powerful features for exposing and using experiment information: the JS API, Optimizely log, and network console.

Use these to debug and QA your experiments and campaigns, similar to how you might use the JavaScript API.

Find audience and campaign IDs

Campaign and audience IDs will help you troubleshoot Optimizely X. Use campaign IDs with the JS API calls below to confirm which experiments or campaigns are active on a page.

Audience IDs help you identify which experience or variation is running on a page. If descriptive names in campaign are masked and identified only by analytics, use audience IDs to confirm which variation was shown.

  1. Navigate to the Campaigns dashboard and select a campaign.

  2. Select the API Names tab to view the campaign or experiment ID, audience IDs, and more.

Useful JS API calls for troubleshooting

The JS API tells you which campaigns, experiments, and variations are running on a page. Below, we provide a few helpful API calls to help you troubleshoot your experiments and campaigns.

For more detailed information and additional JS API calls, check out our developer documentation

optimizely.get('state').getCampaignStates({isActive: true})

An object containing the active campaigns on a given page. For A/B tests this is especially important within Optimizely X Web because the campaign ID is the only ID currently available within the UI.

This object also contains information about each campaign running on a page, including but not limited to:

  • Audiences of a campaign
  • Experiment information
  • Variation information

Returns an array of active experiment IDs on a page.

Remember - in Personalization, there are multiple experiments within a single campaign, but in A/B testing there is only 1 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 of experiment IDs and the corresponding variation ID a user has been bucketed into. Equivalent of classic Optimizely Testing's optimizelyBuckets cookie (which is no longer available within Optimizely X Web).


Provides the hashed unique user ID. Equivalent of classic Optimizely Testing's optimizelyEndUserId cookie (which is no longer available within Optimizely X Web). 


Provides information about the user on the page. Please see our developer docs for more information.


Get the project ID.

    type: "log",
    level: "[VALUE]"

Push log statements that Optimizely keeps track of during execution (see associated section within article). Insert different strings for the [VALUE] to retrieve different levels of information. Different strings available for [VALUE]:

  • OFF - No logs
  • ERROR - Errors only
  • WARN - Warning and above
  • INFO - Info and above
  • DEBUG - Debug and above -- this is the most helpful for troubleshooting
  • ALL - All logs

A page-specific change can only be made when the page in question is active.

The Optimizely log

If you run into issues during your QA process that you can't easily diagnose, the Optimizely log is a valuable resource. Think of the log as a way of "reading Optimizely's mind." Use it to view the decisions that Optimizely made during execution.

Enable console logs

Use a query parameter

You can enable logs by reloading your web page with the query parameter, optimizely_log=info.

If you want to see more or fewer low-level messages, replace info with one of the following "log levels" (listed in order from most terse to most verbose):

  • off : no messages
  • error : only errors (i.e. unexpected conditions that might cause the snippet to run improperly)
  • warn : unusual conditions that might indicate a misconfiguration
  • info: Recommended when you're trying to identify what's running and what's not.
  • debug: May be useful if you're trying to identify why something is or isn't running.
  • all : all messages, including detailed debugging information (intended for developers)

Open your browser's developer console to see the log messages.

Since other JavaScript on the page may have produced console output as the page was loading, you'll need look for the line that says "Optly / Setting log level to." This marks the beginning of the Optimizely logs.

Use the JavaScript API

If you want to reveal messages from the current page load, you can do that with the JavaScript API.

Enter the following in your browser's developer console:

window['optimizely'] = window['optimizely'] || [];
  type: 'log',
  level: 'info'

As before, you can replace info with one of the other "log levels" if you want more or less verbosity.

Open your browser's developer console to see the log messages. The messages will appear directly after the command that you've typed.

Message format

The log messages all follow the same format.

Each message fits on a single line:

The first piece indicates the time at which the message was captured, in milliseconds, relative to the time at which the snippet started to execute:

The second piece, Optly,  indicates that this is a message from the Optimizely snippet:

The optional third piece indicates the general class of behavior that is described by the log message.  In this case, this is a message about page evaluation:

If this piece is missing, it corresponds to the "Main" routine of the snippet.

The remainder is the actual text of the message:

This message may include references to Javascript objects which can be inspected using the console.  In this case, the included Array encodes the page's URL targeting conditions:

Message order

Messages are printed in the same order as the events that they describe.  You may find them easier to follow if you refer back to this flowchart.

Check if you quality for an Audience

Optimizely also logs whether a visitor is in or NOT in each audience when a decisionTicket is generated. You can see this in the log below at optimizely_log=info level and above, along with the audience name and ID.

If you include optimizely_log=debug level or above, you can also inspect the reasons why the visitor was included in the Audience, or not:

What if you don't match the conditions for a behavioral audience as expected?

  1. First, check the corresponding events are firing.

  2. Check that the tag values are scraped properly.

  3. Check that the tag comparison is correct.

Draft article on the console logs has more detail:

Reading the Optimizely log:

Information How to find it in the log

Check what campaigns have been activated

Search for the string "Recording decision"

Bucketed out due to Traffic Allocation

Search for "Recording decision" and check isLayerHoldBack - if set to true the user has been bucketed out of the experiment


Search for the string "Visitor is in audiences"


Campaigns that are not targeted to the page will not appear within the log

Changes made from a campaign

Search for "executing actions" and expand the Object to find different changeSet Object

  • This will include if it is custom code ran on the page
  • It will also include what selector was used for the element and whether the attribute or CSS of the element was changed

The network panel

The network panel is the best place to check for whether an event has fired for your campaign. Like in classic Optimizely Testing, you'll filter the Network panel with the string optimizely and look for the value event after trigger the event on the page (a click event, pageview event, or custom event).

If your test is not live:

  1. Use Preview mode or enable logging by adding ?optimizely_log=info to the URL on your site.

  2. Open the developer console and switch to the console tab.

  3. Search for the event in the console log. Below are some examples of pageview, click, and custom events in the log:

    Example pageview event

    Example click event
    Example custom event

If your test is live:

Check whether an event is being sent to Optimizely's backend for results.

  1. Open the developer console.

  2. Switch to the Network tab.

  3. Filter by "event."

  4. Look for a POST with a status of 200. This indicates that Optimizely logged an event in its counting infrastructure.

  5. Open the Request payload in the headers section to see more details.

Here are some helpful items that are available in the request:

  • eventName 
    • Provides the api_name of the event for click and custom events
    • For pageview events this returns the ID of the page. You can find this value in the Implementation tab of Optimizely X Web when setting up or editing a page
  • eventType
    • For click events, this returns the string "convert"
    • For pageview events, this returns the string "view_activated"
    • For custom events,. this returns the string "other" or the value you specificy when you add the event in the Implementation tab
  • layerStates
    • Lists the campaign, experiment, and variation that an event is attributed to
    • Expand the layerState object to find a layerId and decision to see the associated experiment and variation ID that the event is attributed to

If you see the event in the network traffic but don't see it on the Results page:

  1. Verify that the test has been published and the snippet is up to date.

  2. Check the LayerStates field in the Network traffic. If the layerStates array doesn't include an entry with layerId equal to the Campaign ID, that indicates that the visitor has not activated the campaign before.

    If you expect the campaign to be active on this page, make sure the campaign is running. If you expect the campaign to have been activated in the past on a different domain, you may need to set up cross-origin targeting.