建立指令碼

指令碼會計算針對剩餘人口的傳送內容選擇。 此指令碼會以最高開啟率來恢復傳送的相關資訊,並將內容複製至最終傳送。

指令碼示例

以下指令碼可如同在定位工作流程中使用。 有關詳細資訊,請參閱實施

 // 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

有關指令碼的詳細說明,請參閱指令碼的詳細資訊

實施

  1. 開啟您的​JavaScript code​活動。

  2. Example of a script中提供的指令碼複製到​JavaScript code​窗口。

  3. 在​Label​欄位中,輸入指令碼的名稱,例如:

    <%= vars.deliveryId %>
    

  4. 關閉​JavaScript code​活動。

  5. 儲存您的工作流程。

指令碼的詳細資訊

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

  • 指令碼的第一部分是查詢。 queryDef​命令可讓您從​NmsDelivery​表中恢復通過執行定位工作流建立的傳送,並根據其估計的開啟率對它們進行排序,然後恢復來自具有最高開啟率的傳送的資訊。

    // 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()
    
  • 複製開啟率最高的傳送。

     // 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​添加到該標籤中。

    // 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
    

其他選擇標準

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

  • 最佳點按吞吐量:[indicators/@recipientClickRatio],
  • 最高反應率(開啟電子郵件並點擊訊息):[indicators/@reactivity],
  • 最低投訴率:[indicators/@refusedRatio](對sortDesc屬性使用false值),
  • 最高轉換率:[indicators/@transactionRatio],
  • 收到訊息後瀏覽的頁數:[indicators/@totalWebPage],
  • 最低取消訂閱率:[indicators/@optOutRatio],
  • 事務處理金額:[indicators/@amount]

您現在可以定義最終傳送(請參閱步驟6:定義最終交貨)。

本頁內容

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now