​3. 验证是否已根据定义的轮询间隔检索和缓存设备上决策 规则构件。

  1. 等待轮询间隔的持续时间(默认值为20分钟),并确保SDK正在获取构件。 将输出相同的终端日志。

    此外,应将来自Target跟踪的信息输出到终端,其中包含有关规则工件的详细信息。

    "trace": {
      "clientCode": "your-client-code",
      "artifact": {
        "artifactLocation": "https://assets.adobetarget.com/your-client-code/production/v1/rules.json",
        "pollingInterval": 300000,
        "pollingHalted": false,
        "artifactVersion": "1.0.0",
        "artifactRetrievalCount": 10,
        "artifactLastRetrieved": "2020-09-20T00:09:42.707Z",
        "clientCode": "your-client-code",
        "environment": "production",
        "generatedAt": "2020-09-22T17:17:59.783Z"
      },
    

​4. 通过基于表单的体验编辑器创建测试设备上决策活动,验证通过缓存的规则构件进行的内容交付

  1. 导航到Experience Cloud中的Target用户界面

    替代图像

  2. 使用基于表单的体验编辑器创建新的XT活动。

    替代图像

  3. 输入在Target请求中使用的mbox名称作为XT活动的位置(请注意,这应该是一个专门用于开发的唯一mbox名称)。

    替代图像

  4. 将内容更改为HTML选件或JSON选件。 这将在Target请求中返回到您的应用程序。 将活动的定位保留为“所有访客”,然后选择所需的任何量度。 命名活动,保存活动,然后激活活动以确保使用的mbox/位置仅用于开发。

    替代图像

  5. 在您的应用程序中,为在Target请求的响应中收到的内容添加日志语句

    Node.js SDK

    try {
      const response = await targetClient.getOffers({ request });
      console.log('Response: ', response.response.execute.mboxes[0].options[0].content);
    } catch (error) {
      console.error('Something went wrong', error);
    }
    

    Java SDK

    try {
      Context context = new Context()
        .channel(ChannelType.WEB);
      MboxRequest mbox = new MboxRequest()
        .name("sdk-mbox")
        .index(0);
      ExecuteRequest executeRequest = new ExecuteRequest()
        .mboxes(Arrays.asList(mbox));
    
    
    TargetDeliveryRequest request = TargetDeliveryRequest.builder()
    
    .context(context)
    
    .decisioningMethod(DecisioningMethod.ON_DEVICE)
    
    .execute(executeRequest)
    
    .build();
    
  6. 查看您终端中的日志,以验证您的内容是否正在交付并通过服务器上的规则工件交付。 根据规则工件在设备上确定活动资格和决策时,将输出LD.DeciscionProvider对象。 此外,由于content的日志记录,您应该会看到<div>test</div>,或者您已经决定在创建测试活动时响应此响应。

    记录器输出

    AT: LD.DecisionProvider {...}
    AT: Response received {...}
    Response:  <div>test</div>
    

检查发送通知错误

使用设备上决策时,会自动发送getOffers执行请求的通知。 这些请求将在后台静默发送。 通过订阅名为sendNotificationError的事件可以检查任何错误。 以下代码示例显示了如何使用Node.js SDK订阅通知错误。

const TargetClient = require("@adobe/target-nodejs-sdk");
let client;

function onSendNotificationError({ notification, error }) {
  console.log(
    `There was an error when sending a notification: ${error.message}`
  );
  console.log(`Notification Payload: ${JSON.stringify(notification, null, 2)}`);
}

async function targetClientReady() {
  const request = {
    context: { channel: "web" },
    execute: {
      mboxes: [{
        name: "a1-serverside-ab",
        index: 1
      }]
    }
  };
  const targetResponse = await client.getOffers({ request });
}

client = TargetClient.create({
  events: {
    clientReady: targetClientReady,
    sendNotificationError: onSendNotificationError
  }
});

常见疑难解答方案

当遇到问题时,请务必查看设备上决策的支持的功能。

由于受众或活动不受支持,设备上决策活动无法执行

一个可能发生的常见问题是设备上决策活动由于受众正在使用或活动类型不受支持而无法执行。

(1)使用记录器输出,查看响应对象中trace属性中的条目。 明确标识促销活动属性:

跟踪输出

  "execute": {
  "mboxes": [
    {
      "name": "your-mbox-name",
      "index": 0,
      "trace": {
        "clientCode": "your-client-code",
        ...
        "campaigns": [],
        ...
      }
    }

您会注意到,您尝试符合条件的活动不在campaigns属性中,因为该受众或活动类型不受支持。 如果活动列在campaigns属性下,则问题不是由于不受支持的受众或活动类型所导致。

(2)此外,通过查看日志程序输出中的trace > artifact > artifactLocation找到rules.json文件,并注意到rules > mboxes属性中缺少您的活动:

记录器输出

 ...
 rules: {
   mboxes: { },
   views: { }
 }

最后,导航到Target用户界面并找到相关活动: experience.adobe.com/target

查看受众中使用的规则,并确保仅使用前面提到的受支持的规则。 此外,请确保活动类型为A/B或XT。

替代图像

由于受众不合格,设备上决策活动无法执行

如果设备上决策活动未执行,但您已验证rules.json文件包含该活动,请执行以下步骤来运行:

(1)确保在应用程序中执行的mbox与活动使用的mbox相同:

 ...
 rules: {
   mboxes: {
    target-only-node-sdk-mbox: [{ // this mbox name must match the mbox in your request
      ...
    }]
   }
 ...
 const request = {
   trace: {
     authorizationToken: '2dfc1dce-1e58-4e05-bbd6-a6725893d4d6'
   },
   execute: {
     mboxes: [{
       address: getAddress(req),
       name: "target-only-node-sdk-mbox-two" // this mbox name must match the mbox the activity is using
     }]
   }};
Context context = new Context()
  .channel(ChannelType.WEB);
MboxRequest mbox = new MboxRequest()
  .name("target-only-node-sdk-mbox-two")
  .index(0);
ExecuteRequest executeRequest = new ExecuteRequest()
  .mboxes(Arrays.asList(mbox));

TargetDeliveryRequest request = TargetDeliveryRequest.builder()
  .context(context)
  .decisioningMethod(DecisioningMethod.ON_DEVICE)
  .execute(executeRequest)
  .build();

TargetDeliveryResponse response = targetClient.getOffers(request);

(2)通过查看跟踪输出的matchedRuleConditions或unmatchedRuleConditions属性,确保您符合活动的受众资格:

跟踪输出

...
},
"campaignId": 368564,
"campaignType": "landing",
"matchedSegmentIds": [],
"unmatchedSegmentIds": [
  6188838
      ],
      "matchedRuleConditions": [],
          "unmatchedRuleConditions": [
            {
              "in": [
                "true",
                {
                  "var": "mbox.auth_lc"
                }
              ]
            }
          ]
    ...

如果您有不匹配的规则条件,则不符合活动的条件,因此不会执行活动。 查看受众中的规则,了解您不符合条件的原因。

设备上决策活动未执行,但原因不明确

设备上决策活动无法执行的原因可能并不明显。 在这种情况下,请按照以下故障排除步骤来识别问题:

(1)阅读控制台中的记录器跟踪输出,并识别工件属性,该属性将类似于以下内容:

跟踪输出

...
      "artifact": {
          "artifactLocation": "https://assets.adobetarget.com/your-client-code/production/v1/rules.json",
          "pollingInterval": 300000,
          "pollingHalted": false,
          "artifactVersion": "1.0.0",
          "artifactRetrievalCount": 3,
          "artifactLastRetrieved": "2020-10-16T00:56:27.596Z",
          "clientCode": "adobeinterikleisch",
          "environment": "production"
        },
...

查看工件的artifactLastRetrieved日期,并确保您有最新的rules.json文件下载到应用程序。

(2)在记录器输出中找到evaluatedCampaignTargets属性:

记录器输出

...
  "evaluatedCampaignTargets": [
      {
        "context": {
          "current_timestamp": 1602812599608,
          "current_time": "0143",
          "current_day": 5,
          "user": {
            "browserType": "unknown",
            "platform": "Unknown",
            "locale": "en",
            "browserVersion": -1
          },
          "page": {
            "url": "localhost:3000/",
            "path": "/",
            "query": "",
            "fragment": "",
            "subdomain": "",
            "domain": "3000",
            "topLevelDomain": "",
            "url_lc": "localhost:3000/",
            "path_lc": "/",
            "query_lc": "",
            "fragment_lc": "",
            "subdomain_lc": "",
            "domain_lc": "3000",
            "topLevelDomain_lc": ""
          },
          "referring": {
            "url": "localhost:3000/",
            "path": "/",
            "query": "",
            "fragment": "",
            "subdomain": "",
            "domain": "3000",
            "topLevelDomain": "",
            "url_lc": "localhost:3000/",
            "path_lc": "/",
            "query_lc": "",
            "fragment_lc": "",
            "subdomain_lc": "",
            "domain_lc": "3000",
            "topLevelDomain_lc": ""
          },
          "geo": {},
          "mbox": {},
          "allocation": 23.79
        },
        "campaignId": 368564,
        "campaignType": "landing",
        "matchedSegmentIds": [],
        "unmatchedSegmentIds": [
          6188838
        ],
        "matchedRuleConditions": [],
        "unmatchedRuleConditions": [
          {
            "in": [
              "true",
              {
                "var": "mbox.auth_lc"
              }
            ]
          }
        ]
...

(3)查看context、page和referring数据,确保数据按预期显示,因为这可能会影响活动的定位资格。

(4)查看campaignId,以确保评估您期望执行的一个或多个活动。 campaignId将与TargetUI中活动概述选项卡上的活动ID匹配:

替代图像

(5)查看matchedRuleConditions和unmatchedRuleConditions,以识别在给定活动中符合受众规则条件的问题。

(6)查看最新的rules.json文件,以确保包含要本地执行的一个或多个活动。 上述步骤1中引用了该位置。

(7)确保在请求和活动中使用相同的mbox名称。

(8)确保您使用的是支持的受众规则和支持的活动类型。

即使Target用户界面中的mbox下的活动设置显示“符合设备决策条件”,也会进行服务器调用

进行服务器调用的原因有几个,即使设备符合设备上决策的条件:

  • 当用于“符合设备上决策资格”活动的mbox也用于不符合“符合设备上决策资格”的其他活动时,该mbox将列在rules.json工件的remoteMboxes部分下。 当mbox列在remoteMboxes下时,对该mbox的任何getOffer(s)调用都会导致服务器调用。

  • 如果您在工作区/属性下设置活动,并且在配置SDK时不包含该活动,则可能会导致下载默认工作区的rules.josn,该默认工作区可以使用remoteMboxes部分下的mbox。

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.