[也適用於v8]{class="badge positive" title="亦適用於Campaign v8"}

AB測試:建立指令碼 step-5--creating-the-script

系統會透過指令碼,計算預定用於剩餘母體的傳遞內容選擇。 此指令碼會復原有關最高開啟率之傳送的資訊,並將內容複製到最終傳送。

指令碼範例 example-of-a-script

以下指令碼可依原樣用於目標定位工作流程。 如需詳細資訊,請參閱本章節

 // query the database to find the winner (best open rate)
   var winner = xtk.queryDef.create(
     <queryDef schema="nms:delivery" operation="get">
       <select>
         <node expr="@id"/>
         <node expr="@label"/>
         <node expr="[@operation-id]"/>
         <node expr="[@workflow-id]"/>
       </select>
       <where>
         <condition expr={"@FCP=0 and [@workflow-id]= " + instance.id}/>
       </where>
       <orderBy>
         <node expr="[indicators/@estimatedRecipientOpenRatio]" sortDesc="true"/>
       </orderBy>
     </queryDef>).ExecuteQuery()

   // create a new delivery object and initialize it by doing a copy of
   // the winner delivery
   var delivery = nms.delivery.create()
   delivery.Duplicate("nms:delivery|" + winner.@id)

   // append 'final' to the delivery label
   delivery.label = winner.@label + " final"

   // link the delivery to the operation to make sure it will be displayed in
   // the campaign dashboard. This attribute needs to be set manually here since
   // the Duplicate() method has reset it to its default value => 0
   delivery.operation_id = winner.@["operation-id"]
   delivery.workflow_id = winner.@["workflow-id"]

   // adjust some delivery parameters to make it compatible with the
   // "Prepare and start" option selected in the Delivery tab of this activity
   delivery.scheduling.validationMode = "manual"
   delivery.scheduling.delayed = 0

   // save the delivery in database
   delivery.save()

   // store the new delivery Id in event variables
   vars.deliveryId = delivery.id

如需指令碼的詳細說明,請參閱 本節.

實施 implementation

  1. 開啟您的 JavaScript code 活動。

  2. 複製中提供的指令碼 指令碼範例JavaScript code 視窗。

  3. Label 欄位,輸入指令碼的名稱,即

    code language-none
    <%= vars.deliveryId %>
    

  4. 關閉 JavaScript code 活動。

  5. 儲存您的工作流程。

指令碼的詳細資料 details-of-the-script

本節詳細說明指令碼的各個部分及其作業模式。

  • 指令碼的第一部分是查詢。 此 queryDef 命令可讓您從 NmsDelivery 將執行目標工作流程所建立的傳送加入表格,並根據其預估開啟率進行排序,然後復原開啟率最高的傳送中的資訊。

    code language-none
    // query the database to find the winner (best open rate)
       var winner = xtk.queryDef.create(
         <queryDef schema="nms:delivery" operation="get">
           <select>
             <node expr="@id"/>
             <node expr="@label"/>
             <node expr="[@operation-id]"/>
           </select>
           <where>
             <condition expr={"@FCP=0 and [@workflow-id]= " + instance.id}/>
           </where>
           <orderBy>
             <node expr="[indicators/@estimatedRecipientOpenRatio]" sortDesc="true"/>
           </orderBy>
         </queryDef>).ExecuteQuery()
    
  • 會複製開啟率最高的傳遞。

    code language-none
     // create a new delivery object and initialize it by doing a copy of
     // the winner delivery
    var delivery = nms.delivery.create()
    delivery.Duplicate("nms:delivery|" + winner.@id)
    
  • 已複製傳遞的標籤已修改,而且 final 新增至其中。

    code language-none
    // append 'final' to the delivery label
    delivery.label = winner.@label + " final"
    
  • 傳遞會複製到行銷活動控制面板。

    code language-none
    // link the delivery to the operation to make sure it will be displayed in
    // the campaign dashboard. This attribute needs to be set manually here since
    // the Duplicate() method has reset it to its default value => 0
    delivery.operation_id = winner.@["operation-id"]
    delivery.workflow_id = winner.@["workflow-id"]
    
    code language-none
    // adjust some delivery parameters to make it compatible with the
    // "Prepare and start" option selected in the Delivery tab of this activity
    delivery.scheduling.validationMode = "manual"
    delivery.scheduling.delayed = 0
    
  • 傳遞會儲存在資料庫中。

    code language-none
    // save the delivery in database
    delivery.save()
    
  • 重複傳遞的唯一識別碼會儲存在工作流程變數中。

    code language-none
    // store the new delivery Id in event variables
    vars.deliveryId = delivery.id
    

其他選取條件 other-selection-criteria

上述範例可讓您根據電子郵件開啟率來選取傳送內容。 您可以調整它,以根據其他傳遞特定指標:

  • 最佳點按輸送量: [indicators/@recipientClickRatio]
  • 最高反應率(電子郵件開啟和訊息點按): [indicators/@reactivity]
  • 投訴率最低: [indicators/@refusedRatio] (使用sortDesc屬性的false值),
  • 最高轉換率: [indicators/@transactionRatio]
  • 收到訊息後瀏覽的頁面數: [indicators/@totalWebPage]
  • 最低取消訂閱率: [indicators/@optOutRatio]
  • 交易金額: [indicators/@amount].

您現在可以定義最終傳遞。 了解更多

recommendation-more-help
601d79c3-e613-4db3-889a-ae959cd9e3e1