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
TargetDeliveryResponse 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
1var mboxRequests = new List<MboxRequest>
2 {
3 new (index: 1, name: "home"),
4 new (index: 2, name: "product1"),
5 };
6
7var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
8 .SetPrefetch(new PrefetchRequest(mboxes: mboxRequests))
9 .Build();
10
11// Next, we fetch the offers via Target .NET SDK GetOffers() API
12var targetResponse = targetClient.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 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
1var mboxNotifications = new List<Notification>
2{
3 new (id: "1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
4 mbox: new NotificationMbox("product1", "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"),
5 tokens: new List<string> { "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" })
6};
7
8var mboxNotificationRequest = new TargetDeliveryRequest.Builder()
9 .SetNotifications(mboxNotifications)
10 .Build();

Notice we have 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
var notificationResponse = targetClient.SendNotifications(mboxNotificationRequest);
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.