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.

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: