Get Offers (Node.js)

說明

getOffers()用於執行決定並從Adobe Target擷取體驗。

方法

getOffers

TargetClient.getOffers(options: Object): Promise

參數

options物件具有下列結構:

名稱
類型
必要
預設值
說明
請求
物件
符合Target 傳送API要求
visitorCookie
字串
ECID (VisitorId) Cookie
targetCookie
字串
Target Cookie
targetLocationHint
字串
Target位置提示
consumerId
字串
Analytics for Target (A4T)拼接的consumerIds
CustomerIds
陣列
VisitorId相容格式的客戶ID
sessionId
字串
用於連結多個Target請求
訪客
物件
新VisitorId
提供外部VisitorId例項

Promise

Promise傳回的結構如下:

名稱
類型
說明
請求
物件
Target Delivery API個要求
回應
物件
Target Delivery API個回應
visitorState
物件
應傳遞給訪客API getInstance()的物件
targetCookie
物件
Target Cookie
targetLocationHintCookie
物件
Target位置提示Cookie
analyticsDetails
陣列
使用使用者端Analytics時的Analytics裝載
responseTokens
陣列
回應Token的清單。
trace
陣列
所有請求mbox/檢視的彙總追蹤資料
狀態
物件
包含回應狀態的物件。
決策方法
字串
決定要使用的決策方法(裝置上、伺服器端、混合式)

用來將資料傳回瀏覽器的targetCookietargetLocationHintCookie物件具有以下結構:

名稱
類型
說明
名稱
字串
Cookie 名稱
value
任何
Cookie值,則會轉換為字串
maxAge
數字
maxAge選項可方便您設定相對於目前時間(以秒為單位)的過期時間

用於表示目標回應狀態的status物件具有下列結構:

名稱
類型
說明
狀態
數字
HTTP狀態代碼
訊息
字串
有關回應的訊息。 例如,它可以指出回應是決定裝置上還是伺服器端
remoteMboxes
陣列
當決定方法為on-device時,會提供無法完全決定裝置上的mbox名稱陣列。 換句話說,需要Target Delivery API要求。

範例

Node.js

const TargetClient = require("@adobe/target-nodejs-sdk");
const CONFIG = {
  client: "acmeclient",
  organizationId: "1234567890@AdobeOrg"
};

const targetClient = TargetClient.create(CONFIG);

const request = {
    context: {channel: "web"},
    execute: {
        mboxes: [{
            name: "a1-serverside-ab",
            index: 1
        }]
}};

const response = await targetClient.getOffers({ request });
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3