Menu

Monday, May 2, 2022

Target Server Side implementation using .net SDK

 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

  1. Enable On-Device Decisioning for your organization
  2. Install the SDK
  3. Initialize the SDK
  4. Set up the feature flags in an Adobe Target A/B Test
  5. Implement and render the feature in your application
  6. Implement tracking for events in your application
  7. Activate your A/B activity
Instruction Details :

  1. Enable On-Device Decisioning for your organization
Enabling on-device decisioning ensures an A/B activity is executed at near-zero latency. To enable this feature, navigate to Administration > Implementation > Account details and enable the On-Device Decisioning toggle.


After enabling the On-Device Decisioning toggle, Adobe Target will begin generating rule artifacts for your client.


Output the Target Trace via the terminal to view details about the artifact. To URL is accessible via the artifactLocation variable.


"trace": {
   "clientCode": "your-client-code",
   "artifact": {
     "artifactLocation": "https://assets.adobetarget.com/your-client-code/production/v1/rules.bin",
     "pollingInterval": 300000,
     "pollingHalted": false,
     "artifactVersion": "1.0.0",
     "artifactRetrievalCount": 10,
     "artifactLastRetrieved": "2020-09-20T00:09:42.707Z",
     "clientCode": "your-client-code",
     "environment": "production",
     "generatedAt": "2020-09-22T17:17:59.783Z"
   },


2. Install the SDK

The .NET SDK is distributed by NuGet. To get started, add it as a dependency by installing via Package Manager or .NET CLI:

Install-Package Adobe.Target.Client

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 Attributes

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()

    .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

Target Server Side implementation using .net SDK

 Target Server Side implementation using .net SDK  This reference guide shows how Adobe Target customers can install, initialize, and use th...