預先擷取
預先擷取可讓行動應用程式和伺服器等使用者端在一個要求中擷取多個mbox或檢視的內容、在本地快取,並在訪客造訪這些mbox或檢視時通知Target。
使用預先擷取時,請務必熟悉下列詞語:
prefetch
eventToken
。notifications
eventToken
notifications
陣列中的Target。預先擷取Mbox
使用者端(例如行動應用程式和伺服器)可以在一個工作階段中,預先擷取特定訪客的多個mbox,並加以快取,以避免對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
}
]
}
}'
在prefetch
欄位中,針對工作階段中的訪客,新增一或多個您想要預先擷取至少一次的mboxes
。 預先擷取這些mboxes
後,您會收到下列回應:
{
"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==",
}
]
}
]
}
}
在回應中,您會看到包含要向訪客顯示特定mbox
之體驗的content
欄位。 快取到您的伺服器上時,這非常有用,這樣當訪客在工作階段中與您的網頁或行動應用程式互動,並在您應用程式的任何特定頁面上造訪mbox
時,可以從快取中提供體驗,而不是進行另一個Adobe Target Delivery API呼叫。 不過,當體驗從mbox
傳遞至訪客時,會透過傳送API呼叫傳送notification
,以進行曝光記錄。 這是因為已快取prefetch
個呼叫的回應,這表示訪客在發生prefetch
呼叫時尚未看到體驗。 若要進一步瞭解notification
程式,請參閱通知。
使用Analytics for Target (A4T)時具有clickTrack
個量度的預先擷取mbox
Adobe Analytics for Target (A4T)是跨解決方案的整合,可讓您根據Analytics轉換量度和受眾區段來建立活動。
下列程式碼片段是預先擷取包含clickTrack
個量度的mbox的回應,以通知Analytics已點按選件:
{
"prefetch": {
"mboxes": [
{
"index": 0,
"name": "<mboxName>",
"options": [
...
],
"metrics": [
{
"type": "click",
"eventToken": "<eventToken>",
"analytics": {
"payload": {
"pe": "tnt",
"tnta": "..."
}
}
},
}
],
"analytics": {
"payload": {
"pe": "tnt",
"tnta": "347565:1:0|2,347565:1:0|1"
}
}
}
]
}
}
預先擷取檢視
檢視可更順暢地支援單頁應用程式(SPA)和行動應用程式。 檢視可視為視覺元素的邏輯群組,這些元素共同構成SPA或行動體驗。 現在,透過傳送API,VEC建立的A/B Test和Experience Targeting (X)T活動現在可以預先擷取SPA🔗的檢視上有修改。
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": [{}]
}
}'
上述範例呼叫會預先擷取透過SPA VEC為A/B Test建立的所有檢視,以及要針對網頁channel
顯示的XT活動。 請注意,呼叫會預先擷取有tntId
:84e8d0e211054f18af365d65f45e902b.28_131
的訪客造訪url
:https://target.enablementadobe.com/react/demo/#/
時符合資格的A/B Test或XT活動的所有檢視。
{
"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=="
}
]
}
]
}
}
在回應的content
欄位中,備註中繼資料,例如type
、selector
、cssSelector
和content
,這些中繼資料用於在使用者造訪您的頁面時,將體驗呈現給訪客。 請注意,必要時可以快取prefetched
內容並轉譯給使用者。