const TargetClient = require("@adobe/target-nodejs-sdk");
const CONFIG = {
client: "<your target client code>",
organizationId: "your EC org id",
decisioningMethod: "on-device",
events: {
clientReady: targetClientReady
}
};
const tClient = TargetClient.create(CONFIG);
function targetClientReady() {
//Adobe Target SDK has now downloaded the JSON artifact locally, which contains the activity details.
//We will see how to use the artifact here very soon.
}
var targetClientConfig = new TargetClientConfig.Builder("testClient", "ABCDEF012345677890ABCDEF0@AdobeOrg")
.Build();
this.targetClient.Initialize(targetClientConfig);
Python
code language-python line-numbers
from target_python_sdk import TargetClient
def target_client_ready():
# Adobe Target SDK has now downloaded the JSON artifact locally, which contains the activity details.
# We will see how to use the artifact here very soon.
CONFIG = {
"client": "<your target client code>",
"organization_id": "your EC org id",
"decisioning_method": "on-device",
"events": {
"client_ready": target_client_ready
}
}
target_client = TargetClient.create(CONFIG)
4.機能フラグを Adobe Target A/B テスト アクティビティ
In Targetをクリックし、 アクティビティ ページ、「 」を選択します。 アクティビティを作成 > A/B テスト.
var mbox = new MboxRequest(index: 0, name: "ondevice-featureflag");
var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetContext(new Context(ChannelType.Web))
.SetExecute(new ExecuteRequest(mboxes: new List<MboxRequest> { mbox }))
.Build();
var attributes = targetClient.GetAttributes(request, "ondevice-featureflag");
var flag = attributes.GetString("ondevice-featureflag", "flag");
Python
code language-python line-numbers
# ... Code removed for brevity
feature_flags = {}
def target_client_ready():
attribute_provider = target_client.get_attributes(["ondevice-featureflag"])
feature_flags = attribute_provider.as_object(mbox_name="ondevice-featureflag")
if feature_flags.get("enabled") and feature_flags.get("flag") != "expA": # Assuming "expA" is control
print("Render alternate experience {}".format(feature_flags.get("flag")))
else:
print("Render default experience")
//... Code removed for brevity
//When a conversion happens
TargetClient.sendNotifications({
targetCookie,
"request" : {
"notifications" : [
{
type: "display",
timestamp : Date.now(),
id: "conversion",
mbox : {
name : "orderConfirm"
},
order : {
id: "BR9389",
total : 98.93,
purchasedProductIds : ["J9393", "3DJJ3"]
}
}
]
}
})
Java (Maven)
code language-javascript line-numbers
Notification notification = new Notification();
notification.setId("conversion");
notification.setImpressionId(UUID.randomUUID().toString());
notification.setType(MetricType.DISPLAY);
notification.setTimestamp(System.currentTimeMillis());
Order order = new Order("BR9389");
order.total(98.93);
order.purchasedProductIds(["J9393", "3DJJ3"]);
notification.setOrder(order);
TargetDeliveryRequest notificationRequest =
TargetDeliveryRequest.builder()
.context(new Context().channel(ChannelType.WEB))
.notifications(Collections.singletonList(notification))
.build();
NotificationDeliveryService notificationDeliveryService = new NotificationDeliveryService();
notificationDeliveryService.sendNotification(notificationRequest);
.NET (C#)
code language-csharp line-numbers
var order = new Order
{
Id = "BR9389",
Total = 98.93M,
PurchasedProductIds = new List<string> { "J9393", "3DJJ3" },
};
var notification = new Notification
{
Id = "conversion",
ImpressionId = Guid.NewGuid().ToString(),
Type = MetricType.Display,
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
Order = order,
};
var notificationRequest = new TargetDeliveryRequest.Builder()
.SetContext(new Context(ChannelType.Web))
.SetNotifications(new List<Notification> {notification})
.Build();
targetClient.SendNotifications(notificationRequest);
Python
code language-python line-numbers
# ... Code removed for brevity
# When a conversion happens
notification_mbox = NotificationMbox(name="orderConfirm")
order = Order(id="BR9389, total=98.93, purchased_product_ids=["J9393", "3DJJ3"])
notification = Notification(
id="conversion",
type=MetricType.DISPLAY,
timestamp=1621530726000, # Epoch time in milliseconds
mbox=notification_mbox,
order=order
)
notification_request = DeliveryRequest(notifications=[notification])
target_client.send_notifications({
"target_cookie": target_cookie,
"request" : notification_request
})