Edit in GitHubLog an issue

Send Notifications

Description#

sendNotifications() is used to send display or click notifications to Adobe Target for measurement and reporting.

SDK methods that will increment an impression automatically are:

  • getOffers()
  • getAttributes()

When a prefetch object is passed within the request, the impression is not automatically incremented for the activities with mboxes within the prefetch object. sendNotifications() must be used for prefetched experiences for incrementing impressions and conversions.

Method#

Copied to your clipboard
ResponseStatus TargetClient.sendNotifications(TargetDeliveryRequest request)

Example#

First, let's build the Target Delivery API request for prefetching content for the home and product1 mboxes.

Copied to your clipboard
1List<MboxRequest> mboxRequests = new ArrayList<>();
2mboxRequests.add((MboxRequest) new MboxRequest().name("home").index(1));
3mboxRequests.add((MboxRequest) new MboxRequest().name("product1").index(2));
4PrefetchRequest prefetchMboxesRequest = new PrefetchRequest().setMboxes(mboxRequests)
5
6// Next, we fetch the offers via Target Java SDK getOffers() API
7TargetDeliveryResponse targetResponse = targetJavaClient.getOffers(targetDeliveryRequest);

A successful response will contain a Target Delivery API response object, which contains prefetched content for the requested mboxes. A sample targetResponse.response object may look as follows:

Copied to your clipboard
1{
2 "status": 200,
3 "requestId": "e8ac2dbf5f7d4a9f9280f6071f24a01e",
4 "id": {
5 "tntId": "08210e2d751a44779b8313e2d2692b96.21_27"
6 },
7 "client": "adobetargetmobile",
8 "edgeHost": "mboxedge21.tt.omtrdc.net",
9 "prefetch": {
10 "mboxes": [
11 {
12 "index": 0,
13 "name": "home",
14 "options": [
15 {
16 "type": "html",
17 "content": "HOME OFFER",
18 "eventToken": "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
19 "responseTokens": {
20 "profile.memberlevel": "0",
21 "geo.city": "dublin",
22 "activity.id": "302740",
23 "experience.name": "Experience B",
24 "geo.country": "ireland"
25 }
26 }
27 ],
28 "state": "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"
29 },
30 {
31 "index": 1,
32 "name": "product1",
33 "options": [
34 {
35 "type": "html",
36 "content": "TEST OFFER 1",
37 "eventToken": "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
38 "responseTokens": {
39 "profile.memberlevel": "0",
40 "geo.city": "dublin",
41 "activity.id": "302740",
42 "experience.name": "Experience B",
43 "geo.country": "ireland"
44 }
45 }
46 ],
47 "state": "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"
48 }
49 ]
50 }
51}

Note the mbox name and state fields, as well as the eventToken field, in each of the Target content options. These should be provided in the sendNotifications() request, as soon as each content option is displayed. Let's suppose the product1 mbox has been displayed on a non-browser device. The notifications request will look like this:

Copied to your clipboard
1TargetDeliveryRequest mboxNotificationRequest = TargetDeliveryRequest.builder().notifications(new ArrayList() {{
2 add(new Notification()
3 .id("1")
4 .timestamp(System.currentTimeMillis())
5 .type(MetricType.DISPLAY)
6 .mbox(new NotificationMbox()
7 .name("product1")
8 .state("J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U")
9 )
10 .tokens(Arrays.asList(new String[]{"t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="}))
11 );
12}}).build();

Notice that we've included both the mbox state and the event token corresponding to the Target offer delivered in the prefetch response. Having built the notifications request, we can send it to Target via sendNotifications() API method:

Copied to your clipboard
ResponseStatus notificationResponse = targetJavaClient.sendNotifications(mboxNotificationRequest);
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.