Skip to main content

Everything you need to switch from Optimizely Classic to X in one place: See the Optimizely X Web Transition Guide.

Optimizely Knowledge Base

Read the Optimizely X log

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

  • Read the Optimizely log to see whether an event passes or fails
  • Check whether an experiment or campaign is loading
  • Check if you qualify for an audience condition
  • Check if changes on a page are publishing

The Optimizely log is a valuable resource. It allows you to "read Optimizely's mind" by printing the execution of targeting and activation decisions, variation changes, events, and third-party integrations on a page in your browser's console. Use it to investigate issues that you can't otherwise easily diagnose. 

The log can help you check:

  • If an experiment or campaign is loading correctly

  • If you qualify for an audience condition

  • If changes you make on a page are applied

There are two ways to enable the log: with a query parameter or the JavaScript API.

Looking for a more technical resource? Find out more about the log in our developer documentation.

Enable the log with a query parameter

You can enable log by adding a query parameter before you load the page. Here's how:

  1. Add the query parameter:optimizely_log=info.

  2. Then, reload the page to read the log.

If you're familiar with Optimizely Classic, you may be accustomed to using the "log" API to read the logs for the current page load. In Optimizely X, we've updated the client so you must append the optimizely_log parameter, then reload the page to see the log. This change minimizes the logging overhead for visitors and pageviews that don't request the log.

Enable the log with the JavaScript API

  1. Open your browser's developer console.

  2. To reveal messages from the page load, use the JavaScript API. Append the query parameter and push the log before the snippet loads to see information from the current page load.

    window['optimizely'] = window['optimizely'] || [];
      type: 'log',
      level: 'info'
  3. Other JavaScript on the page may have produced console output as the page was loading, so you'll need to find where the Optimizely log starts.

    Search for a line that starts with: "Setting log level to..."

To modify the verbosity of the messages, replace info with one of the levels below (listed from terse to 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)

Reading the log

Messages are printed in the same chronological order as the events that occur. You may find them easier to follow if you refer to this flowchart. You'll need to append the query parameter before you load the page to see the log.

The log messages all follow the same format. Here's an example:

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:

Check if you qualify for an audience

Optimizely  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 see why a 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 if if the corresponding events are firing.

  2. Check that the tag values are scraped properly.

  3. Check that the tag comparison is correct.

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"

Campaign targeting

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 objects

  • This will also include if custom code has run on the page

  • This will also include what selector was used for the element and whether the attribute or CSS of the element was changed