发送通知(.NET)
描述
SendNotifications()
用于向Adobe Target发送显示或单击通知以进行测量和报告。
NOTE
当具有所需参数的
Execute
对象位于请求本身中时,展示次数将自动递增,以用于符合条件的活动。将自动增加展示次数的SDK方法为:
GetOffers()
GetAttributes()
在请求中传递Prefetch
对象时,对具有Prefetch
对象中的mbox的活动,展示次数不会自动递增。 SendNotifications()
必须用于预获取的体验,以增加展示次数和转化次数。
方法
创建
TargetDeliveryResponse TargetClient.SendNotifications(TargetDeliveryRequest request)
示例
首先,让我们构建Target Delivery API请求以预取home
和product1
mbox的内容。
.NET
var mboxRequests = new List<MboxRequest>
{
new (index: 1, name: "home"),
new (index: 2, name: "product1"),
};
var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
.SetPrefetch(new PrefetchRequest(mboxes: mboxRequests))
.Build();
// Next, we fetch the offers via Target .NET SDK GetOffers() API
var targetResponse = targetClient.GetOffers(targetDeliveryRequest);
成功的响应将包含Target Delivery API响应对象,其中包含所请求mbox的预获取内容。 示例targetResponse.Response
对象可能如下所示:
.NET
{
"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
名称和state
字段以及eventToken
字段。 每个内容选项显示后,即应在SendNotifications()
请求中提供这些选项。 假设product1
mbox已显示在非浏览器设备上。 通知请求将显示如下:
.NET
var mboxNotifications = new List<Notification>
{
new (id: "1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
mbox: new NotificationMbox("product1", "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"),
tokens: new List<string> { "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" })
};
var mboxNotificationRequest = new TargetDeliveryRequest.Builder()
.SetNotifications(mboxNotifications)
.Build();
请注意,我们已在预获取响应中包含与投放的Target选件相对应的mbox状态和事件令牌。 生成通知请求后,我们可以通过SendNotifications()
API方法将其发送给Target:
.NET
var notificationResponse = targetClient.SendNotifications(mboxNotificationRequest);
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3