You can preview campaigns and variations of your App Personalization experiences as they'll appear to app users. There are two ways of previewing 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 app. You'll see the campaign only if you meet the targeting conditions and frequency settings. The experience served will be the one with the highest priority (that you are targeted for), and you'll be served variations according to the allocation. Because this includes draft experiences, you can QA experiences and campaigns before serving them to your users.
Previewing variations and campaigns
1. Select what you want to preview.
-
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 Preview icon.
The preview dialog appears.
2. Configure and view the preview:
- In the Preview on field, enter the deep link to your app, where you want to inject the variation code. Note that every time the link is edited, a new QR code is created.
- 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.
Optionally:
- Send an email with the preview URL to other reviewers.
- Click Copy URL to save it or to view without the QR code.
Notes:
- 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:
http://acme.com/dyApiPreview=5f30be92-dbd3-4053-904b-f83cd885574b
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[].
{
"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":"https://shop.biz/", "locale":"en_US"
},
"device": { "userAgent":"Mozilla/5.0 (X11; Linux x86_64) Chrome/56.0.29", "ip":"54.100.200.255"}
},
}
{
"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"
}
{
"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 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 the 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.