发送通知(Java)

描述

sendNotifications()用于向Adobe Target发送显示或单击通知以进行测量和报告。

NOTE
当具有所需参数的execute对象位于请求本身中时,展示次数将自动递增,以用于符合条件的活动。

将自动增加展示次数的SDK方法为:

  • getOffers()
  • getAttributes()

在请求中传递prefetch对象时,对具有prefetch对象中的mbox的活动,展示次数不会自动递增。 sendNotifications()必须用于预获取的体验,以增加展示次数和转化次数。

方法

创建

ResponseStatus TargetClient.sendNotifications(TargetDeliveryRequest request)

示例

首先,让我们构建Target Delivery API请求以预取homeproduct1 mbox的内容。

预取

List<MboxRequest> mboxRequests = new ArrayList<>();
mboxRequests.add((MboxRequest) new MboxRequest().name("home").index(1));
mboxRequests.add((MboxRequest) new MboxRequest().name("product1").index(2));
PrefetchRequest prefetchMboxesRequest = new PrefetchRequest().setMboxes(mboxRequests)

// Next, we fetch the offers via Target Java SDK getOffers() API
TargetDeliveryResponse targetResponse = targetJavaClient.getOffers(targetDeliveryRequest);

成功的响应将包含Target Delivery API响应对象,其中包含所请求mbox的预获取内容。 示例targetResponse.response对象可能如下所示:

响应

{
  "status": 200,
  "requestId": "e8ac2dbf5f7d4a9f9280f6071f24a01e",
  "id": {
    "tntId": "08210e2d751a44779b8313e2d2692b96.21_27"
  },
  "client": "adobetargetmobile",
  "edgeHost": "mboxedge21.tt.omtrdc.net",
  "prefetch": {
    "mboxes": [
      {
        "index": 0,
        "name": "home",
        "options": [
          {
            "type": "html",
            "content": "HOME OFFER",
            "eventToken": "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
            "responseTokens": {
              "profile.memberlevel": "0",
              "geo.city": "dublin",
              "activity.id": "302740",
              "experience.name": "Experience B",
              "geo.country": "ireland"
            }
          }
        ],
        "state": "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"
      },
      {
        "index": 1,
        "name": "product1",
        "options": [
          {
            "type": "html",
            "content": "TEST OFFER 1",
            "eventToken": "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
            "responseTokens": {
              "profile.memberlevel": "0",
              "geo.city": "dublin",
              "activity.id": "302740",
              "experience.name": "Experience B",
              "geo.country": "ireland"
            }
          }
        ],
        "state": "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"
      }
    ]
  }
}

记下Target内容选项中的每个mbox namestate字段以及eventToken字段。 每个内容选项显示后,即应在sendNotifications()请求中提供这些选项。 假设product1 mbox已显示在非浏览器设备上。 通知请求将如下所示:

请求

TargetDeliveryRequest mboxNotificationRequest = TargetDeliveryRequest.builder().notifications(new ArrayList() {{
    add(new Notification()
            .id("1")
            .timestamp(System.currentTimeMillis())
            .type(MetricType.DISPLAY)
            .mbox(new NotificationMbox()
                    .name("product1")
                    .state("J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U")
            )
            .tokens(Arrays.asList(new String[]{"t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="}))
    );
}}).build();

请注意,我们已在预获取响应中包含与投放的Target选件相对应的mbox状态和事件令牌。 生成通知请求后,我们可以通过sendNotifications() API方法将其发送给Target:

响应

ResponseStatus notificationResponse = targetJavaClient.sendNotifications(mboxNotificationRequest);
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3