Force behaviors using query parameters

  • Updated
  • Optimizely Web Experimentation
  • Optimizely Performance Edge
  • Optimizely Personalization

Force parameters are disabled by default in Optimizely to help protect the privacy of your account.

Optimizely Performance Edge is a lightweight experimentation product that delivers significantly faster performance than previous versions of Optimizely Web Experimentation. It does this by relying on a streamlined "microsnippet" that limits the range of available features.

Optimizely Performance Edge and Optimizely Web Experimentation handle force parameters the same way, so all information contained in this article applies to experiments created with either version.

To use force parameters, follow these steps:

  1. Go to Settings Implementation.
    If you have custom snippets, you will have to edit the custom snippet by clicking the name then scrolling down to Privacy.
  2. Deselect Disable the force variation parameter. See more information about that setting.
  3. If you want to force variations for draft or paused experiments to appear, select Allow anyone to view draft or paused experiments. Remember, this setting lets anyone view your draft or paused changes simply by adding optimizely_token=PUBLIC.
  4. Append the query parameter to your site's URL. 
  5. after you are done, return your settings to the default mode. Go to Settings > Implementation Settings to select Disable the force variation parameter.

Optimizely Web Experimentation and Optimizely Performance Edge let 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 are not too technically complex or dependent on timing. 

For example, if you change the text or an image on your homepage, you can append a query parameter to view the 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:

  • Test variations outside of the editor
  • Create a JavaScript log
  • Disable Optimizely Web Experimentation and Optimizely Performance Edge code on a page
  • View draft or paused experiments (with the help of a public token)

Essentially, you add a query parameter to the end of a URL on your site that tells Optimizely Web Experimentation and Optimizely Performance Edge which variation or experience to run when the page loads. You can also force yourself into an audience with the optimizely_x_audiences=audienceId  query parameter. For a list of query parameters you can use, see below.

  • Forcing a variation to run will disable all other variations and experiments that are running on the page.
  • Forcing a variation or audience will not force an experiment or Page to activate. You will still need to meet the URL Targeting and Activation conditions.

Query parameters

The basic syntax for force parameters in Optimizely Web Experimentation and Optimizely Performance Edge.

  • 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:

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

    You can force multiple variations across experiments by comma-separating different variation IDs. For example, to see a Variation with the ID 1234567890 from experiment 1, and a Variation with the ID 9876543210 from experiment 2:

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

    With Performance Edge, you can use force parameters only on published and running experiments.

  • Enable tracking while using the force parameter
    ?optimizely_force_tracking=true

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

  • Force a variation or personalized experience from a draft or paused experiment to display.
    ?optimizely_x=VARIATIONID&optimizely_token=PUBLIC

    For example, to see variation with ID 1234567890 of a draft experiment:

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

    To use this parameter, you 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:

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

    You can use a comma-separated list of Audience IDs, such as: optimizely_x_audiences=1123581220,987654321,510203040 (for audiences with these IDs: 1123581220, 987654321, 510203040).

  • Create a JavaScript log in the browser console
    ?optimizely_log=true

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

  • Disable Optimizely Web Experimentation and Optimizely Performance Edge from running on the page.
    ?optimizely_disable=true

    For example:  

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

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

Query parameters in a running experiment

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

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

Force variations for paused or draft mode experiments or campaigns

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

?optimizely_token=PUBLIC
To use the public token, you must select Allow anyone to view draft or paused experiments in the Project Settings. Enable this setting with care because it lets anyone view your draft or paused changes by appending optimizely_token=PUBLIC to the Preview URL. Disable this setting after you finished testing.

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

If your site has the URL http://atticandbutton.us/. If you run an experiment with the ID 123456 and you want to force yourself into variation with ID 1234567890:

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

If you pause your experiment, and you want to view variation with ID 2345678901 of the paused experiment, 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 use manual or conditional activation: 

  • Manual activation – the parameter activates a running experiment only
  • Conditional activation – the parameter activates the experiment only if the activation conditions are met (that is, the conditional activation code evaluates to true)