文件TargetTarget開發人員指南

使用屬性執行功能測試

最後更新: 2025年5月5日
  • 主題:
  • APIs/SDKs

建立對象:

  • 開發人員

步驟摘要

  1. 為您的組織啟用on-device decisioning
  2. 建立A/B Test活動
  3. 定義您的A和B
  4. 新增對象
  5. 設定流量分配
  6. 將流量分佈設為變數
  7. 設定報告
  8. 新增追蹤KPI的量度
  9. 實作程式碼以使用屬性執行功能測試
  10. 實作程式碼以追蹤轉換事件
  11. 使用屬性啟用功能測試
注意
假設您是一間零售電子商務公司。 當客戶瀏覽及排序您的產品目錄時,您想要提高轉換率。 您有假設認為,某些排序演演算法和分頁策略會產生比其他演演算法更好的結果。 為了測試此理論,您決定執行功能測試,該測試涉及使用一般使用者的不同排序選項來重新設計排序Widget。 您想要確保此功能測試會在幾乎零延遲的情況下執行,以免對使用者體驗造成負面影響,並扭曲結果。

1.為您的組織啟用on-device decisioning

啟用裝置上決策可確保在幾乎零延遲的情況下執行A/B活動。 若要啟用此功能,請瀏覽至Adobe Target中的​ Administration > Implementation > Account details,並啟用​ On-Device Decisioning ​切換按鈕。

替代影像

注意
您必須擁有管理員或核准者使用者角色,才能啟用或停用​ On-Device Decisioning ​切換功能。

啟用​ On-Device Decisioning ​切換後,Adobe Target會開始為您的使用者端產生​ 規則成品。

2.建立A/B Test活動

  1. 在Adobe Target中,導覽至​ Activities ​頁面,然後選取​ Create Activity > A/B test。

    替代影像

  2. 在​ Create A/B Test Activity ​強制回應視窗中,保留預設的​ Web ​選項為已選取(1)、選取​ Form ​作為您的體驗撰寫器(2)、選取具有​ No Property Restrictions (3)的​ Default Workspace,然後按一下​ Next (4)。

    替代影像

3.定義您的A和B

  1. 在活動建立的​ Experiences ​步驟中,提供活動的名稱(1)並新增第二個體驗,即體驗B,方法是按一下​ Add Experience (2)按鈕。 輸入應用程式中要使用屬性執行特徵測試的位置(3)名稱。 在下列範例中,product-results-page是為體驗A定義的位置。(也是為體驗B定義的位置。)

    替代影像

    Experience A ​將包含代表您商業邏輯執行下列動作的JSON:

    • 透過test_sorting功能標幟啟動排序演演算法功能
    • 執行sorting_algorithm _**_attribute中定義的建議排序演演算法
    • 依pagination_limit中定義的分頁策略所定義,每頁傳回50項產品
  2. 在體驗A中,按一下以選取​ Create JSON Offer,將內容從​ Default Content ​變更為JSON,如下所示(1)。

    替代影像

  3. 定義具有test_sorting、sorting_algorithm和pagination_limit旗標和屬性的JSON,這些旗標和屬性將用於起始分頁限製為50個產品的建議排序演演算法。

    注意
    當Adobe Target儲存使用者以檢視體驗A時,將會傳回範例中具有已定義屬性的JSON。 在您的程式碼中,您需要檢查功能標幟test_sorting的值,以檢視是否應開啟排序功能。 若是如此,您將會使用sorting_algorithm屬性的建議值,在產品清單檢視中顯示建議產品。 為您的應用程式顯示的產品限制將為50,因為這是pagination_limit屬性的值。

    替代影像

    Experience B ​將定義代表您的商業邏輯執行下列動作的JSON:

    • 透過test_sorting功能旗標啟動排序演演算法功能
    • 執行sorting_algorithm _**_attribute中定義的best_sellers排序演演算法
    • 依pagination_limit中定義的分頁策略所定義,每頁傳回50項產品
    注意
    當Adobe Target儲存使用者以檢視體驗B時,將會傳回範例中具有已定義屬性的JSON。 在您的程式碼中,您需要檢查功能標幟test_sorting的值,以檢視是否應開啟排序功能。 若是如此,您將會使用sorting_algorithm屬性的best_sellers值,在產品清單檢視中顯示最暢銷的產品。 為您的應用程式顯示的產品限制將為50,因為這是pagination_limit屬性的值。

    替代影像

4.新增對象

在​ Targeting ​步驟中,保留​ All Visitors ​對象。 這可讓您瞭解排序功能的影響,以及哪個演演算法和專案數量對結果影響最大。

替代影像

5.設定流量分配

定義訪客百分比,以用來測試排序演演算法和分頁策略。 換言之,您要將這個測試轉出到您的使用者中哪個百分比? 在此範例中,若要將此測試部署給所有登入的使用者,請將流量分配維持在100%。

替代影像

6.將流量分佈設為變數

定義會看見建議與最暢銷商品排序演演算法的訪客百分比,限製為每頁50項產品。 在此範例中,流量分配在體驗A和B之間維持50/50的分割比例。

替代影像

7.設定報告

在​ Goals & Settings ​步驟中,選擇​ Adobe Target ​作為​ Reporting Source,以便在Adobe Target UI中檢視您的A/B測試結果,或選擇​ Adobe Analytics ​以便在Adobe Analytics UI中檢視這些結果。

替代影像

8.新增追蹤KPI的量度

選擇​ Goal Metric ​以使用屬性測量功能測試。 在此範例中,成功取決於使用者是否購買產品,取決於他們看到的排序演演算法和分頁策略。

9.使用屬性實施功能測試至您的應用程式

Node.js
const TargetClient = require("@adobe/target-nodejs-sdk");
const options = {
  client: "testClient",
  organizationId: "ABCDEF012345677890ABCDEF0@AdobeOrg",
  decisioningMethod: "on-device",
  events: {
    clientReady: targetClientReady
  }
};
const targetClient = TargetClient.create(options);

function targetClientReady() {
  return targetClient.getAttributes(["product-results-page"]).then(function(attributes) {
    const test_sorting = attributes.getValue("product-results-page", "test-sorting");
    const sorting_algorithm = attributes.getValue("product-results-page", "sorting_algorithm");
    const pagination_limit = attributes.getValue("product-results-page", "pagination_limit");
  });
}
Java
import com.adobe.target.edge.client.ClientConfig;
import com.adobe.target.edge.client.TargetClient;
import com.adobe.target.delivery.v1.model.ChannelType;
import com.adobe.target.delivery.v1.model.Context;
import com.adobe.target.delivery.v1.model.ExecuteRequest;
import com.adobe.target.delivery.v1.model.MboxRequest;
import com.adobe.target.edge.client.entities.TargetDeliveryRequest;
import com.adobe.target.edge.client.model.TargetDeliveryResponse;

ClientConfig config = ClientConfig.builder()
    .client("testClient")
    .organizationId("ABCDEF012345677890ABCDEF0@AdobeOrg")
    .build();
TargetClient targetClient = TargetClient.create(config);
MboxRequest mbox = new MboxRequest().name("product-results-page").index(0);
TargetDeliveryRequest request = TargetDeliveryRequest.builder()
    .context(new Context().channel(ChannelType.WEB))
    .execute(new ExecuteRequest().mboxes(Arrays.asList(mbox)))
    .build();
Attributes attributes = targetClient.getAttributes(request, "product-results-page");
String testSorting = attributes.getString("product-results-page", "test-sorting");
String sortingAlgorithm = attributes.getString("product-results-page", "sorting_algorithm");
String paginationLimit = attributes.getString("product-results-page", "pagination_limit");

10.實作程式碼以追蹤轉換事件

Node.js
//... Code removed for brevity

//When a conversion happens
TargetClient.sendNotifications({
    targetCookie,
    "request" : {
      "notifications" : [
        {
          type: "click",
          timestamp : Date.now(),
          id: "conversion",
          mbox : {
            name : "product-results-page"
          }
        }
      ]
    }
})
Java
ClientConfig config = ClientConfig.builder()
  .client("acmeclient")
  .organizationId("1234567890@AdobeOrg")
  .build();
TargetClient targetClient = TargetClient.create(config);

Context context = new Context().channel(ChannelType.WEB);

ExecuteRequest executeRequest = new ExecuteRequest();

NotificationDeliveryService notificationDeliveryService = new NotificationDeliveryService();

Notification notification = new Notification();
notification.setId("conversion");
notification.setImpressionId(UUID.randomUUID().toString());
notification.setType(MetricType.CLICK);
notification.setTimestamp(System.currentTimeMillis());
notification.setTokens(
    Collections.singletonList(
        "IbG2Jz2xmHaqX7Ml/YRxRGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));

TargetDeliveryRequest targetDeliveryRequest =
    TargetDeliveryRequest.builder()
        .context(context)
        .execute(executeRequest)
        .notifications(Collections.singletonList(notification))
        .build();

TargetDeliveryResponse offers = targetClient.getOffers(request);
notificationDeliveryService.sendNotification(request);

Attributes attributes = targetClient.getAttributes(request, "product-results-page");
String testSorting = attributes.getString("product-results-page", "test-sorting");
String sortingAlgorithm = attributes.getString("product-results-page", "sorting_algorithm");
String paginationLimit = attributes.getString("product-results-page", "pagination_limit");

11.使用屬性啟用功能測試

替代影像

recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3