Invia notifiche (.NET)
- Argomenti:
- APIs/SDKs
Creato per:
- Sviluppatore
Descrizione
SendNotifications()
viene utilizzato per inviare notifiche di visualizzazione o clic a Adobe Target per la misurazione e il reporting.
Execute
con parametri obbligatori si trova all'interno della richiesta stessa, l'impression verrà incrementata automaticamente per le attività idonee.I metodi SDK che incrementano automaticamente un’impression sono:
GetOffers()
GetAttributes()
Quando un oggetto Prefetch
viene passato all'interno della richiesta, l'impression non viene incrementata automaticamente per le attività con mbox all'interno dell'oggetto Prefetch
. SendNotifications()
deve essere utilizzato per le esperienze preacquisite per incrementare impressioni e conversioni.
Metodo
Creare
TargetDeliveryResponse TargetClient.SendNotifications(TargetDeliveryRequest request)
Esempio
Innanzitutto, compiliamo la richiesta Target Delivery API per preacquisire il contenuto per le mbox home
e product1
.
.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);
In caso di esito positivo, la risposta conterrà un oggetto di risposta Target Delivery API contenente contenuto prerecuperato per le mbox richieste. Un oggetto targetResponse.Response
di esempio potrebbe essere visualizzato come segue:
.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"
}
]
}
}
Prendere nota del nome mbox
e dei campi state
, nonché del campo eventToken
, in ciascuna delle opzioni di contenuto Target. Questi devono essere forniti nella richiesta SendNotifications()
, non appena viene visualizzata ogni opzione di contenuto. Supponiamo che la mbox product1
sia stata visualizzata su un dispositivo non browser. La richiesta di notifica verrà visualizzata come segue:
.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();
Si noti che sono stati inclusi sia lo stato mbox che il token evento corrispondente all'offerta Target consegnata nella risposta di preacquisizione. Dopo aver generato la richiesta di notifiche, è possibile inviarla a Target tramite il metodo API SendNotifications()
:
.NET
var notificationResponse = targetClient.SendNotifications(mboxNotificationRequest);