Prefetching allows clients like mobile apps and servers to fetch content for multiple mboxes or views in one request, cache it locally, and later notify Target when the user visits those mboxes or views.
When utilizing prefetch, it’s important to be familiar with the following terms:
Field Name | Description |
---|---|
prefetch |
List of mboxes and views that should be fetched but shouldn’t be marked as visited. The Target Edge returns an eventToke n for each mbox or view that exist in the prefetch array. |
notifications |
List of mboxes and views that were previously prefetched and should be marked as visited. |
eventToken |
A hashed encrypted token that is returned when content is prefetched. This token should be sent back to Target in the notifications array. |
Clients like mobile apps and servers can prefetch multiple mboxes for a given user within a session and cache it in order to avoid multiple calls to Adobe Target Delivery API.
curl -X POST \
'https://demo.tt.omtrdc.net/rest/v1/delivery?client=demo&sessionId=7abf6304b2714215b1fd39a870f01afc#1555632114' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '
{
"id": {
"tntId": "abcdefghijkl00023.1_1"
},
"context": {
"channel": "web",
"browser" : {
"host" : "demo"
},
"address" : {
"url" : "http://demo.dev.tt-demo.com/demo/store/index.html"
},
"screen" : {
"width" : 1200,
"height": 1400
}
},
"prefetch": {
"mboxes" : [
{
"name" : "SummerOffer",
"index" : 1
},
{
"name" : "SummerShoesOffer",
"index" : 2
},
{
"name" : "SummerDressOffer",
"index" : 3
}
]
}
}'
Within the prefetch
field, add one or more mboxes
you want to prefetch for at once for a user within a session. Once you prefetch for those mboxes
you will receive the following response:
{
"status": 200,
"requestId": "5efee0d8-3779-4b12-a74e-e04848faf191",
"client": "demo",
"id": {
"tntId": "abcdefghijkl00023.1_1"
},
"edgeHost": "mboxedge28.tt.omtrdc.net",
"prefetch": {
"mboxes": [
{
"index": 1,
"name": "SummerOffer",
"options": [
{
"content": "<p><b>Enjoy this 15% discount on your next purchase</b></p>",
"type": "html",
"eventToken": "GcvBXDhdJFNR9E9r1tgjfmqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
}
]
},
{
"index": 2,
"name": "SummerShoesOffer",
"options": [
{
"content": "<p><b>Enjoy this 15% discount on your next shoe purchase</b></p>"
"type": "html",
"eventToken": "GcvBXDhdJFNR9E9r1tgjfmqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
}
]
},
{
"index": 3,
"name": "SummerDressOffer",
"options": [
{
"content": "<p><b>Enjoy this 15% discount on your next dress purchase</b></p>"
"type": "html",
"eventToken": "GcvBXDhdJFNR9E9r1tgjfmqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
}
]
}
]
}
}
Within the response, you will see the content
field containing the experience to show to the user for a particular mbox
. This is very useful when cached on your server so that when a user interacts with your web or mobile application within a session and visits an mbox
on any particular page of your application, the experience can be delivered from the cache instead of making another Adobe Target Delivery API call. However, when an experience is delivered to the user from the mbox
, a notification
will be sent via a Delivery API call in order for impression logging to occur. This is because the response of prefetch
calls are cached, which means that the user has not seen the experiences at the time the prefetch
call happens. In order to learn more about the notification
process, please see Notifications.
Views support Single Page Applications (SPA) and Mobile Applications more seamlessly. Views can be seen as a logical group of visual elements that together make up a SPA or Mobile experience. Now, through the Delivery API, VEC created AB & XT activities with modifications on Views for SPA can now be prefetched.
curl -X POST \
'https://demo.tt.omtrdc.net/rest/v1/delivery?client=demo&sessionId=a3e7368c62d944c0855d424cd7a03ab0' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"id": {
"tntId": "84e8d0e211054f18af365d65f45e902b.28_131"
},
"context": {
"channel": "web",
"window": {
"width": 1819,
"height": 842
},
"browser": {
"host": "target.enablementadobe.com"
},
"address": {
"url": "https://target.enablementadobe.com/react/demo/#/"
}
},
"prefetch": {
"views": [{}]
}
}'
The example call above will prefetch all the Views created thru the SPA VEC for AB and XT activities to display for the web channel
. Notice in the call that we want to prefetch all the Views from the AB or XT activities that a visitor with tntId
:84e8d0e211054f18af365d65f45e902b.28_131
who is visiting the url
:https://target.enablementadobe.com/react/demo/#/
qualifies for.
{
"status": 200,
"requestId": "14ce028e-d2d2-4504-b3da-32740fa8dd61",
"client": "demo",
"id": {
"tntId": "84e8d0e211054f18af365d65f45e902b.28_131"
},
"edgeHost": "mboxedge28.tt.omtrdc.net",
"prefetch": {
"views": [
{
"id": 228,
"name": "checkout-express",
"key": "checkout-express",
"state": "Vqfb6kYGAmzWOLf9W6E+Q/0LyS+SYe2h5tuTXzRNnkjKkZaZZr2ijp41/6AwK6fdFgADhFNC7l5efUCs9shgTw==",
"options": [
{
"content": [
{
"type": "setHtml",
"selector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION.section:eq(0) > DIV.container:eq(0) > FORM.col-md-4:eq(0) > DIV:nth-of-type(1) > DIV.mb-3:eq(2)",
"cssSelector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION:nth-of-type(1) > DIV:nth-of-type(1) > FORM:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(3)",
"content": "<span style=\"color:#000080;\"><strong>*We charge an additional fee of $12.34 for faster delivery. If you choose express delivery get 15% off on your next order.</strong></span>"
}
],
"type": "actions",
"eventToken": "N3C13I0M2PH8iaKtONJlFJNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="
}
]
},
{
"id": 5,
"name": "home",
"key": "home",
"state": "Vqfb6kYGAmzWOLf9W6E+Q/0LyS+SYe2h5tuTXzRNnkjKkZaZZr2ijp41/6AwK6fdFgADhFNC7l5efUCs9shgTw==",
"options": [
{
"content": [
{
"type": "setHtml",
"selector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION.section:eq(0) > DIV.container:eq(1) > DIV.heading:eq(0) > H1.title:eq(0)",
"cssSelector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(1) > H1:nth-of-type(1)",
"content": "<span style=\"color:#800000;\"><strong>Trending Items</strong></span>"
}
],
"type": "actions",
"eventToken": "N3C13I0M2PH8iaKtONJlFJNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="
}
]
},
{
"id": 6,
"name": "products",
"key": "products",
"state": "Vqfb6kYGAmzWOLf9W6E+Q/0LyS+SYe2h5tuTXzRNnkjKkZaZZr2ijp41/6AwK6fdFgADhFNC7l5efUCs9shgTw==",
"options": [
{
"content": [
{
"type": "setStyle",
"selector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION.section:eq(0) > DIV.container:eq(0) > DIV.heading:eq(0) > BUTTON.btn:eq(0)",
"cssSelector": "#app > DIV:nth-of-type(1) > DIV:nth-of-type(2) > SECTION:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > BUTTON:nth-of-type(1)",
"content": {
"background-color": "rgba(191,0,0,1)",
"priority": "important"
}
}
],
"type": "actions",
"eventToken": "N3C13I0M2PH8iaKtONJlFJNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="
}
]
}
]
}
}
In the content
fields of the response, note metadata such as type
, selector
, cssSelector
, and content
, which are used to render the experience to your end user when a user visits your page. Note that the prefetched
content can be cached and rendered to the user when necessary.