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
TargetClient.sendNotifications(options: Object): Promise

Parameters#

options has the following structure:

NameTypeRequiredDefault
requestObjectYesNone

Example#

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

Copied to your clipboard
1const prefetchMboxesRequest = {
2 prefetch: {
3 mboxes: [
4 { name: "home" },
5 { name: "product1" }
6 ]
7 }
8};
9// Next, we fetch the offers via Target Node.js SDK getOffers() API
10const targetResponse = await targetClient.getOffers({ request: prefetchMboxesRequest });

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 appear 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 appear as follows:

Copied to your clipboard
1const mboxNotificationRequest = {
2 notifications: [{
3 id: "1",
4 timestamp: Date.now(),
5 type: "display",
6 mbox: {
7 name: "product1",
8 state: "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"
9 },
10 tokens: [ "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" ]
11 }]
12};

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 the sendNotifications() API method:

Copied to your clipboard
const notificationResponse = await targetClient.sendNotifications({ request: mboxNotificationRequest });
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.