This article explains how to preview API campaigns and Product Listing Page campaigns. To preview site personalization campaigns (such as Overlay or Dynamic Content), see Previewing Site Personalization Campaigns.
Previewing is relevant for API server-side campaigns in both hybrid and API-only modes.
You can preview campaigns and variations of your site personalization experiences as if they were published on your site. There are two ways of previewing that help you test and view all aspects of your campaigns:
- Previewing a variation: View a variation, regardless if you meet any targeting conditions. In this mode, variation code is simply injected into the page. This is useful to QA the variation code, look and feel.
- Previewing a campaign: View it exactly as a visitor experience it on your site, including draft experiences. Meaning, you will only see the campaign if you meet the targeting conditions and frequency settings. You will see the experience with the highest priority (that you are targeted for), and you will be served to variations according to the allocation. Since it includes draft experiences, it allows you to QA experiences and campaigns before serving them to your visitors.
Enabling preview mode
To preview API campaigns, your application must request the preview mode. This is a one-time change that your developer makes, and after that – previewing variations and campaigns no longer requires any development effort.
When you click Preview for a campaign or variation in the Dynamic Yield console, the website opens with the URL parameter dyApiPreview=[token]. For example:
http://acme.com/dyApiPreview=5f30be92-dbd3-4053-904b-f83cd885574b
As a developer, you should add logic: If the dyApiPreview URL parameter exists in the current URL – you should include the preview token in the API request under the preview.ids[].
{
"user": { "id": "yaexono4ohphania" },
"session": { "custom": "iquahngaishe2koh" },
"selector": {
"names": ["PDP Top Banner", "PDP Recs"],
“preview”: {
ids: [“PREVIEW TOKEN”] // This is where you inject the preview token from the URL parameter
}
},
"context": {
// The usual context...
}
}
{
"choices": [
{
"id": 551993,
"name": "HP Top Banner",
"type": "DECISION",
"variations": [
{
"id": 25863143,
"payload": {
"type": "CUSTOM_JSON",
"data": {
"image": "http://lorempixel.com/400/200/",
"title": "Stay Sharp",
"subtitle": "Set the tone of elegance",
"cta": "Buy Now",
"link": ""
}
}
}
],
"decisionId": "l7QtNTg5MTkwODkyNDA4MTM1NDM3Oc4AEHLBpzk5MzA1ODQBkJHOAYqj56UzNjQzOQ=="
}
],
"isPreviewMode": true
}}
Notes
- The preview token scope is for the whole request. Meaning, it will "enable" all draft experiences in the campaigns. If you wish to preview drafts from a single campaign only – separate the requests.
- The preview tokens expire after 2 weeks.
- A new preview token will be generated every time that the "Preview" button is clicked.
- When you request a preview mode for multiple campaigns, you will get is the best option “targeted at me” from all the live and draft ones.
- If you send an invalid preview token, you will get a warning: Request contains invalid previewID
- If you send a request with no preview token (meaning, a live production call) – only "Active" 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, simply separate tokens with a comma. This is useful if you want to preview multiple variations, from different campaigns, at once. If you include multiple tokens, tokens for previewing a variation take precedence over tokens for previewing a campaign.
Previewing variations
When creating or editing a variation, you can use the Preview On Site button or the Preview icon to see how the variation will look on your site. You can preview variations even if the variation is not saved yet.
Simply enter the page in which you want to inject the variation code, and click Preview On Site.
A new tab opens in preview mode. The variation is visible whether or not you match the targeting conditions of the experiences. However, the campaign's trigger conditions (for example, an overlay that is triggered after 30 seconds on a page) must be met for the variation to display. If you do not match these conditions, you see a message explaining why the variation wasn't served.
Previewing campaigns
- Go to API Campaigns, hover over any campaign and click the preview
icon.
- Choose the preview URL, and click Preview. The page opens in preview mode.
- You can also email preview URLs to your colleagues, so that they can preview the campaign without entering the Dynamic Yield console.
Notice: Variation preview represent a snapshot of the variation code at the moment of generating the preview links. Links will remain active for 45 days. - When previewing a campaign, all targeting, trigger and frequency are considered before serving it.
- Preview mode will remain active until you close the tab.