Edit in GitHubLog an issue

Getting Started with Target SDKs

In order to get up and running, we encourage you to create your first on-device decisioning feature flag activity in the language of your choice:

  • Node.js
  • Java
  • .NET
  • Python

Summary of steps#

  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

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.

alt image

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

2. Install the SDK#

For Node.js, Java, and Python, run the following command in your project directory in the terminal. For .NET, add it as a dependency by installing from NuGet.

Copied to your clipboard
npm i @adobe/target-nodejs-sdk -P
Copied to your clipboard
1const TargetClient = require("@adobe/target-nodejs-sdk");
2
3const CONFIG = {
4 client: "<your target client code>",
5 organizationId: "your EC org id",
6 decisioningMethod: "on-device",
7 events: {
8 clientReady: targetClientReady
9 }
10};
11
12const tClient = TargetClient.create(CONFIG);
13
14function targetClientReady() {
15 //Adobe Target SDK has now downloaded the JSON artifact locally, which contains the activity details.
16 //We will see how to use the artifact here very soon.
17}

4. Set up the feature flags in an Adobe Target A/B Test#

  1. In Adobe Target, navigate to the Activities page, then select Create Activity > A/B test.

    alt image

  2. In the Create A/B Test Activity modal, leave the default Web option selected (1), select Form as your experience composer (2), select Default Workspace with No Property Restrictions(3), then click Next (4).

    alt image

  3. In the Experiences step of activity creation, provide a name for your activity (1) and add a second experience, Experience B, by clicking Add Experience (2). Enter the location name of your choice (3). For example, ondevice-featureflag or homepage-addtocart-featureflag are location names indicating the destinations for feature flag testing. In the example shown below, ondevice-featureflag is the location defined for Experience B. Optionally, you may add Audience Refinements (4) to restrict qualification to the activity.

    alt image

  4. In the CONTENT section on the same page, select Create JSON Offer in the drop-down (1) as shown.

alt image

  1. In the JSON Data text box that appears, type your feature flag variables for each experience (1), using a valid JSON object (2).

    Enter the feature flag variables for Experience A.

    alt image

    Enter the feature flag variables for Experience B.

    alt image

  1. Click Next (1) to advance to the Targeting step of activity creation.

    alt image

  2. In the Targeting step example shown below, Audience Targeting (2) remains on the default set of All Visitors, for simplicity. This means the activity is untargeted. However, note Adobe recommends you always target your audiences for production activities. Click Next (3) to advance to the Goals & Settings step of activity creation.

    alt image

  3. In the Goals & Settings step, set Reporting Source to Adobe Target (1). Define the Goal Metric as Conversion, specifying the details based on your site's conversion metrics (2). Click Save & Close (3) to save the activity.

    alt image

5. Implement and render the feature in your application#

After setting up the feature flag variables in Adobe Target, modify your application code to use them. For example, after getting the feature flag in the application, you can use it to enable features and render the experience for which the visitor qualified.

Copied to your clipboard
1//... Code removed for brevity
2
3let featureFlags = {};
4
5function targetClientReady() {
6 tClient.getAttributes(["ondevice-featureflag"]).then(function(response) {
7 const featureFlags = response.asObject("ondevice-featureflag");
8 if(featureFlags.enabled && featureFlags.flag !== "expA") { //Assuming "expA" is control
9 console.log("Render alternate experience" + featureFlags.flag);
10 }
11 else {
12 console.log("Render default experience");
13 }
14 });
15}

6. Implement additional tracking for events in your application#

Optionally, you may send additional events for tracking conversions using the sendNotification() function.

Copied to your clipboard
1//... Code removed for brevity
2
3//When a conversion happens
4TargetClient.sendNotifications({
5 targetCookie,
6 "request" : {
7 "notifications" : [
8 {
9 type: "display",
10 timestamp : Date.now(),
11 id: "conversion",
12 mbox : {
13 name : "orderConfirm"
14 },
15 order : {
16 id: "BR9389",
17 total : 98.93,
18 purchasedProductIds : ["J9393", "3DJJ3"]
19 }
20 }
21 ]
22 }
23})

7. Activate your A/B activity#

  1. Click Activate (1) to activate your A/B activity.

alt image

Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.