系統會透過指令碼,計算預定用於剩餘母體的傳遞內容選擇。 此指令碼會復原有關最高開啟率之傳送的資訊,並將內容複製到最終傳送。
以下指令碼可依原樣用於目標定位工作流程。 如需詳細資訊,請參閱本章節。
// 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
如需指令碼的詳細說明,請參閱 本節.
開啟您的 JavaScript code 活動。
複製中提供的指令碼 指令碼範例 到 JavaScript code 視窗。
在 Label 欄位,輸入指令碼的名稱,即
<%= vars.deliveryId %>
關閉 JavaScript code 活動。
儲存您的工作流程。
本節詳細說明指令碼的各個部分及其作業模式。
指令碼的第一部分是查詢。 此 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]
.您現在可以定義最終傳遞。 了解更多。