Skip to main content
menu_icon.png

Everything you need to learn Optimizely X in one place: See our resource pages for Web Experimentation and Personalization.

x
Optimizely Knowledge Base

Force behaviors in Optimizely X using query parameters

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

THIS ARTICLE WILL HELP YOU:
  • Use a query parameter, aka the "force parameter," to preview a specific variation of an experiment in Optimizely Classic
  • Use additional query parameters to:
    • Create a JavaScript log in the browser console
    • Disable Optimizely from running on a page

Optimizely lets you use URL parameters to force a specific variation or personalized experience to appear. The parameters let you skip all targeting conditions (like audiences) and force the variation code to execute on the page. Force parameters are best used to check changes that aren't too technical complex or dependent on timing. 

For example, let's say you change the text or an image on your homepage. You can simply append a query parameter to quickly view change without worrying about having to meet the targeting conditions. 

Force variation parameters are also a great way to share variations with key stakeholders.

They help you:

  • QA variations outside of the Editor

  • Create a JavaScript log

  • Disable Optimizely code on a page

  • View draft or paused experiments (with the help of a public token, see below)

Essentially, you add a query parameter to the end of any URL on your site. It tells Optimizely which variation or experience to run when the page loads, regardless of targeting conditions such as audience targeting and URL targeting.

Parameters at a glance

Here's the basic syntax for force parameters in Optimizely. 

Force a variation or personalized experience from a running, published experiment to display

?optimizely_x=VARIATIONID

For example, to see a Variation with the ID "1234567890" in an experiment, you'd use this:

http://www.atticandbutton.us?optimizely_x=1234567890

Force a variation or personalized experience from a draft or paused experiment to displa

?optimizely_x=VARIATIONID&optimizely_token=PUBLIC

For example, to see Variation with ID "1234567890" of a draft experiment, you'd use this:

http://www.atticandbutton.us?optimizely_x=1234567890&optimizely_token=PUBLIC

To use this parameter, you'll need to enable certain Privacy Settings.

Force yourself into a specific audience

?optimizely_x_audiences=AUDIENCESID

For example, if your Audience ID is "1123581220" and you want to view an experiment or campaign as that audience, you'd use this:

http://www.atticandbutton.us?optimizely_x_audiences=1123581220

Create a JavaScript log in the browser console

?optimizely_log=true

For example: http://www.atticandbutton.us/?optimizely_log=true

Disable Optimizely from running on the page

?optimizely_disable=true

For example:  

http://www.atticandbutton.us/?optimizely_disable=true

To find experiment, variation, and audience IDs, navigate to API Names in your experiment or Personalization campaign.

Experiments or campaigns that are running

When you use query parameters in a running experiment, the variation you force will display and your variation mapping will be updated in localStorage. 

If you were previously bucketed in a different variation, the force parameter updates that bucketing. You'll then be persistently bucketed into the new variation.

Experiments or campaigns that are paused or in draft mode

You can use a public token to force variations for draft or paused experiments, if you're willing to allow anyone to view draft or paused experiments. You'll need to enable this parameter in your project's privacy settings.

Here's the parameter:

?optimizely_token=PUBLIC 

If you've been using Optimizely Classic, this token allows you to have similar functionality and QA multiple variations across devices with a simple parameter.

To use the public token, you must check Allow anyone to view draft or paused experiments in Project Settings. Enable this setting with care. It allows anyone to view your draft or paused changes by appending optimizely_token=PUBLIC to the Preview URL. Disable this setting once you've finished QA.

Alternatively, use the Share Link feature to show draft variations and experiences that haven't been published to team members without exposing these variations or experiences as broadly.

Force parameters are disabled by default in Optimizely to help protect the privacy of your account. To use them, follow these steps:

  1. Navigate to Settings >  Privacy Settings. 

  2. Uncheck the Disable the force variation parameter box. Here's more information about that setting.

  3. If you'd like to force variations for draft or paused experiments to appear, check the Allow anyone to view draft or paused experiments box. Remember, this setting allows anyone to view your draft or paused changes simply by adding optimizely_token=PUBLIC .

  4. Append the query parameter to your site's URL see your variations. Below, we show a couple of examples.

  5. Once you're done, return your settings to the default mode. Navigate to Settings > Privacy Settings to check Disable the force variation parameter.

Let's imagine your site has the URL http://atticandbutton.us/. If you're running an experiment with the ID "123456" and you'd like to force yourself into variation with ID "1234567890," the URL and parameter will look like this:

http: //atticandbutton.us/?optimizely_x=1234567890

Now let's say you pause your experiment, and you'd like to view variation with ID "2345678901" of the paused experiment. First, you'll enable the public token. Then, view the variation with this URL and query parameter:

http: //atticandbutton.us/?optimizely_x=2345678901&optimizely_token=PUBLIC

Manual and conditional activation

If you're using manual or conditional activation, here's what you need to know: 

  • Manual activation: the parameter will only activate a running experiment

  • Conditional activation: the parameter only activates the experiment if the activation conditions are met (i.e. the conditional activation code evaluates to true)