Target Server Side implementation using .net SDK
This reference guide shows how Adobe Target customers can install, initialize, and use the .NET SDK.
Reference : https://adobetarget-sdks.gitbook.io/docs/sdk-reference-guides/dotnet-sdk/install-sdk
https://adobetarget-sdks.gitbook.io/docs/getting-started/dotnet
Sample Application : https://github.com/adobe/target-dotnet-sdk/tree/main/SampleApp
Summary of Steps for SDK implementation
- Enable On-Device Decisioning for your organization
- Install the SDK
- Initialize the SDK
- Set up the feature flags in an Adobe Target A/B Test
- Implement and render the feature in your application
- Implement tracking for events in your application
- Activate your A/B activity
- Enable On-Device Decisioning for your organization
Administration > Implementation > Account details
and enable the On-Device Decisioning toggle.Output the Target Trace via the terminal to view details about the artifact. To URL is accessible via the
artifactLocation
variable.Package Manager
or .NET CLI
:3. Initialize SDK
Use the Create
method in order to initialize the .NET SDK and instantiate the Target Client to make calls to Adobe Target for experiments and personalized experiences.
When using .NET Dependency Injection, just add the SDK at service configuration step by calling services.AddTargetLibrary();
, then inject ITargetClient targetClient
in your app's constructor.
After this, use the Initialize
method of the SDK to configure the SDK, thus completing the initialization step.
var targetClientConfig = new TargetClientConfig.Builder("acmeclient", "ABCDEF012345677890ABCDEF0@AdobeOrg") .Build();
targetClient = TargetClient.Create(targetClientConfig);
// make calls to Adobe Target
4. Get Offers
GetOffers() is used to execute a decision and retrieve an experience from Adobe Target.
var targetClientConfig = new TargetClientConfig.Builder("acmeClient", "ABCDEF012345677890ABCDEF0@AdobeOrg") .Build(); var targetClient = TargetClient.Create(targetClientConfig); var mboxRequests = new List<MboxRequest> { new (index: 1, name: "a1-serverside-ab") }; var targetDeliveryRequest = new TargetDeliveryRequest.Builder() .SetExecute(new ExecuteRequest(mboxes: mboxRequests)) .Build(); var targetResponse = targetClient.GetOffers(targetDeliveryRequest);
5. Get Attributesvar targetClientConfig = new TargetClientConfig.Builder("acmeClient", "ABCDEF012345677890ABCDEF0@AdobeOrg")
.Build();
var targetClient = TargetClient.Create(targetClientConfig);
var mboxRequests = new List<MboxRequest> { new (index: 1, name: "a1-serverside-ab") };
var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
.Build();
var offerAttributes = targetClient.GetAttributes(targetDeliveryRequest, "demo-engineering-flags");
//returns just the value of searchProviderId from the mbox offer
var searchProviderId = offerAttributes.GetString("demo-engineering-flags", "searchProviderId");
//returns a simple Dictionary representing the mbox offer
var engineeringFlags = offerAttributes.ToMboxDictionary("demo-engineering-flags");
// the value of engineeringFlags looks like this
// {
// "cdnHostname": "cdn.cloud.corp.net",
// "searchProviderId": 143,
// "hasLegacyAccess": false
// }
var assetUrl = $"http://{engineeringFlags["cdnHostname"]}/path/to/asset";
6. Send Notifications
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 consider that the Product1 mbox has been displayed on a non-browser device. The notifications request will look like this:
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();
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:
When to use device decsioning?
suppose your marketing team is running ad campaigns to attract prospects to your home page.
Running ad campaigns on publisher networks requires payment, therefore any prospect that lands on
your home page translates to a dollar amount. At the same time, suppose you are running A/B experiments to see which hero image best captures your consumer's attention. If delivering those A/B experiments takes an additional 2 seconds, there is a high likelihood the consumer will become impatient and bounce. There go your marketing dollars and A/B experiments! Losing this hard-earned prospect is difficult, since any opportunity of converting this prospect to a loyal or repeat customer is now forfeited.
Therefore, running an on-device decisioning activity for this use case can avoid any negative impact that latency can introduce.
No comments:
Post a Comment