규칙 아티팩트는 SDK 초기화 단계 중에 다운로드됩니다. 초기화 단계를 사용자 정의하여 아티팩트가 다운로드되고 사용되는 방법을 결정할 수 있습니다.
Node.js
code language-js line-numbers
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 테스트 활동
위치 Target로 이동한 다음 활동 페이지를 선택한 다음 활동 만들기 > A/B 테스트.
다음에서 A/B 테스트 활동 만들기 모달에서 기본 웹 옵션을 선택한 상태로 둡니다(1). 다음을 선택합니다. 양식 경험 작성기 (2)로서 기본 작업 영역 포함 속성 제한 없음(3) 을 클릭한 다음 다음 (4)
다음에서 경험 활동 만들기 단계에서 활동(1)의 이름을 입력하고 를 클릭하여 두 번째 경험인 경험 B를 추가합니다. 경험 추가 (2) 선택한 위치 이름을 입력합니다(3). 예를 들어, ondevice-featureflag 또는 homepage-addtocart-featureflag 기능 플래그 테스트 대상을 나타내는 위치 이름입니다. 아래 표시된 예에서는 ondevice-featureflag 은 경험 B에 대해 정의된 위치입니다. 필요에 따라 대상 세분화(4)를 추가하여 활동에 자격을 제한할 수 있습니다.
다음에서 콘텐츠 동일한 페이지의 섹션에서 다음을 선택합니다. JSON 오퍼 만들기 (1)을 클릭합니다.
다음에서 JSON 데이터 표시되는 텍스트 상자에 유효한 JSON 개체(2)를 사용하여 각 경험(1)에 대한 기능 플래그 변수를 입력합니다.
경험 A에 대한 기능 플래그 변수를 입력합니다.
(위의 경험 A에 대한 샘플 JSON)
code language-json line-numbers
{
"enabled" : true,
"flag" : "expA"
}
경험 B에 대한 기능 플래그 변수를 입력합니다.
(위의 경험 B에 대한 샘플 JSON)
code language-json line-numbers
{
"enabled" : true,
"flag" : "expB"
}
클릭 다음 (1) (으)로 이동 타겟팅 활동 만들기 단계입니다.
다음에서 타겟팅 아래 표시된 단계 예와 같이, 단순성을 위해 대상 타깃팅(2)은 모든 방문자의 기본 세트에 유지됩니다. 즉, 활동이 타깃팅되지 않습니다. 그러나 참고 Adobe은 항상 프로덕션 활동의 대상을 타기팅하는 것을 권장합니다. 클릭 다음 (3) (으)로 이동 목표 및 설정 활동 만들기 단계입니다.
다음에서 목표 및 설정 단계, 설정 보고 소스 끝 Adobe Target (1) 다음을 정의합니다. 목표 지표 다음으로: 전환 를 클릭하고 사이트의 전환 지표를 기반으로 세부 사항을 지정합니다(2). 클릭 저장 및 닫기 (3) 활동을 저장합니다.
5. 응용 프로그램에서 기능 구현 및 렌더링
에서 기능 플래그 변수를 설정한 후 Target를 클릭하고 애플리케이션 코드를 수정하여 이를 사용합니다. 예를 들어 애플리케이션에서 기능 플래그를 가져온 후 이를 사용하여 기능을 활성화하고 방문자가 자격을 부여받은 경험을 렌더링할 수 있습니다.
Node.js
code language-js line-numbers
//... Code removed for brevity
let featureFlags = {};
function targetClientReady() {
tClient.getAttributes(["ondevice-featureflag"]).then(function(response) {
const featureFlags = response.asObject("ondevice-featureflag");
if(featureFlags.enabled && featureFlags.flag !== "expA") { //Assuming "expA" is control
console.log("Render alternate experience" + featureFlags.flag);
}
else {
console.log("Render default experience");
}
});
}
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")
6. 애플리케이션의 이벤트에 대한 추가 추적 구현
선택적으로 sendNotification() 함수를 사용하여 전환 추적을 위한 추가 이벤트를 보낼 수 있습니다.
Node.js
code language-js line-numbers
//... 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
})