La elección del contenido de entrega destinado a la población restante se calcula mediante una secuencia de comandos. Esta secuencia de comandos recupera la información relativa a la entrega con la mayor tasa de apertura y copia el contenido en la entrega final.
El siguiente script se puede utilizar como se encuentra en el flujo de trabajo de direccionamiento. Para obtener más información, consulte esta sección.
// 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
Para ver un ejemplo detallado de un script, consulte esta sección.
Abra la actividad JavaScript code.
Copie la secuencia de comandos ofrecida en Ejemplo de secuencia de comandos en la ventana JavaScript code.
En el campo Label, introduzca el nombre de la secuencia de comandos, por ejemplo.
<%= vars.deliveryId %>
Cierre la actividad JavaScript code.
Guarde el flujo de trabajo.
En esta sección se detallan las distintas partes de la secuencia de comandos y su modo operativo.
La primera parte de la secuencia de comandos es una consulta. El comando queryDef permite recuperar desde la tabla NmsDelivery los envíos creados ejecutando el flujo de trabajo objetivo y ordenarlos en función de su tasa estimada de apertura. A continuación, se recupera la información de la entrega con la mayor tasa de apertura.
// 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()
Se duplica la entrega con la mayor tasa de apertura.
// 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)
La etiqueta de la entrega duplicado se modifica y la palabra final se añade a ella.
// append 'final' to the delivery label
delivery.label = winner.@label + " final"
La entrega se copia en el tablero de campañas.
// 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
La entrega se guarda en la base de datos.
// save the delivery in database
delivery.save()
El identificador único de la entrega duplicado se almacena en la variable del flujo de trabajo.
// store the new delivery Id in event variables
vars.deliveryId = delivery.id
El ejemplo de arriba permite seleccionar el contenido de una entrega según la tasa de apertura de los correos electrónicos. Se puede adaptar para que poder basarse en otros indicadores específicos de entrega:
[indicators/@recipientClickRatio]
,[indicators/@reactivity]
,[indicators/@refusedRatio]
(utilice el valor falso para el atributo sortDesc),[indicators/@transactionRatio]
,[indicators/@totalWebPage]
,[indicators/@optOutRatio]
,[indicators/@amount]
.Ahora puede definir la entrega final. Más información.