Previewing API Campaigns

This article explains how to preview API server-side campaigns. To preview script-based campaigns, see our Knowledge Base article

You can preview campaigns and variations of your site personalization experiences as if they were published on your site. There are two ways to preview that help you test and view all aspects of your campaigns:

  • Preview a variation: View a variation, regardless of whether you meet any targeting conditions. In this mode, the variation's code is simply injected into the page. This is useful to QA the code and the variation look and feel.
  • Preview a campaign: View it exactly as a visitor would experience it on your site. This means you'll see the campaign only if you meet the targeting conditions and frequency settings. You'll see the experience with the highest priority you're targeted for and be served variations according to the allocation. Because this includes draft experiences, you can QA experiences and campaigns before serving them to your visitors.

Previewing web personalization campaigns

Previewing variations

You can preview variations even if they haven't been saved.

  1. While editing or creating a variation, click Preview On Site.
  2. Enter the URL of the site on which you want to preview the variation.

A new tab opens, displaying the preview.

Note that the variation is displayed whether or not you match the targeting conditions of the experience. However, the campaign's trigger conditions must be met (for example, an overlay that's triggered after 30 seconds). If the trigger condition isn't met, a message appears explaining why the variation wasn't served.

Previewing campaigns

  1. Hover over the API campaign you want to preview, then click the preview (eye) icon for the one you want to preview.
  1. Do one of the following:

    • Enter the preview URL (if not already there) and click Preview. The page opens in preview mode.

    • Email the preview URL to your colleagues so they can preview the campaign without entering the Experience OS console.
      Note: Variation previews represent a snapshot of the variation code at the moment the preview link is generated. Links remain active for 45 days.

Note that when you preview a campaign, all targeting, triggers, and frequency are considered before serving it.

Preview mode remains active until you close the tab.

Previewing app personalization campaigns

To preview a variation: While creating or editing the variation, click Preview in app. You can preview variations even if they haven't been saved.

To preview a campaign: Hover over the API campaign you want to preview, and then click the Previewpreview icon.png icon.

The preview dialog appears:

Configure and view:

  1. In the Preview on field, enter the deep link to your app, where you want to inject the variation code. Note that a new QR code is created every time the link is edited.
  2. Scan the QR with any device that has both a camera and your app installed. The QR code directs you to the location in your app along with the campaign’s preview token, and the variation is displayed.


  1. Send an email with the preview URL to other reviewers.
  2. Click Copy URL to save it or to view it without the QR code.



  • When you preview a campaign, all targeting conditions are considered before serving it.
  • Variation previews represent a snapshot of the variation code at the moment the preview link is generated.
  • Links remain active for 45 days.

Enabling preview mode

To preview API campaigns, your application must request the preview mode. This is a one-time change that your developer makes. Afterward, previewing variations and campaigns no longer requires any development effort.

When you click Preview for a campaign or variation in the Experience OS console, the website opens with the URL parameter dyApiPreview=[token]. For example:

As a developer, add the logic: If the dyApiPreview URL parameter exists in the current URL, include the preview token in the API request under the preview.ids[].

Choose request body -- preview mode

"user": {"dyid": "1679843083476146043", 
“dyid_server”: "1679843083476146043" }, 
"session":{"dy": "a2719b4d6c4709128bf5f57a3bf3"}, 
"selector": { 
     "names": ["PDP Top Banner", "PDP Recs"],
   “preview”: {
        "ids": [“PREVIEW TOKEN”] // This is where you inject the preview token from the URL parameter
"context": { 
   "page": { "type":"HOMEPAGE", "location":"", "locale":"en_US" 
   "device": { "userAgent":"Mozilla/5.0 (X11; Linux x86_64) Chrome/56.0.29", "ip":""} 

Choose response -- preview mode

"cookies": [ 
      {"name": "_dyid_server", "value": "16798430146043", "maxAge": "63072000"},
      {"name": "_dyjsession", "value": "a2719b4d6c470383f1bf3", "maxAge": "63072000"}
  "choices": [
      "id": 5,
      "name": "Homepage Banner Main",
      "type": "DECISION",
      "decisionId": "aGVsbG8K",
      "isPreview": true,
      "variations": [
          "id": 52,
          "payload": {
"type": "CUSTOM_JSON",
"data": {
  "key1": "value1",
  "key2": "value2"


  • The preview token scope is for the whole request. Meaning, it will "enable" all draft experiences in the campaigns. If you want to preview drafts from a single campaign only, separate the requests.
  • The preview tokens expire after 2 weeks.
  • A new preview token is generated every time Preview is clicked.
  • When you request the preview mode for multiple campaigns, you will get the best option (based on the targeting you match) from all the live and draft campaigns.
  • If you send an invalid preview token, you'll get a warning: Request contains invalid previewID.
  • If you send a request with no preview token (meaning, a live production call), only active-status experiences are considered. Campaigns that include only draft or paused experiences will return empty choices.
  • You can include multiple preview tokens in a single call by separating the tokens with a comma. This is useful if you want to preview multiple variations from different campaigns at the same time. If you include multiple tokens, tokens for previewing a variation take precedence over tokens for previewing a campaign.
  • Note the difference between campaign-level preview tokens and variation-level tokens:
    • A preview token at the campaign level returns the parameter "isPreviewMode": true at the end of the response, which causes all returned campaigns to be viewed in preview mode.
    • A variation-level preview token returns the parameter "isPreview": true within the "choices" parameter of each variation separately, if the token matches a variation.