A escolha do conteúdo de delivery destinado à população restante é calculada por um script. Este script recupera as informações relacionadas à delivery com a mais alta taxa de abertura e copia o conteúdo para a delivery final.
O script a seguir pode ser usado no fluxo de trabalho de direcionamento. Para obter mais informações, consulte esta seção.
// 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 verificar uma explicação detalhada do script, consulte esta seção.
Abra a atividade JavaScript code.
Copie o script oferecido no Exemplo de um script na janela JavaScript code.
No campo Label, digite o nome do script, ou seja,
<%= vars.deliveryId %>
Feche a atividade JavaScript code.
Salve o fluxo de trabalho.
Esta seção detalha as várias partes do script e seu modo operacional.
A primeira parte do script é uma query. O comando queryDef permite recuperar da tabela NmsDelivery os deliveries criados executando o workflow para construção do target e ordenando com base na taxa estimada de abertura, então as informações do delivery com a taxa mais alta de abertura são recuperadas.
// 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()
A delivery com a taxa mais alta de abertura é duplicada.
// 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)
O rótulo da delivery duplicada é modificado e a palavra final é adicionada a ele.
// append 'final' to the delivery label
delivery.label = winner.@label + " final"
A delivery é copiada no painel de campanha.
// 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
A delivery é salva no banco de dados.
// save the delivery in database
delivery.save()
O identificador único da delivery duplicada é armazenado na variável do workflow.
// store the new delivery Id in event variables
vars.deliveryId = delivery.id
O exemplo acima permite selecionar o conteúdo de uma delivery com base na taxa de abertura de e-mails. É possível adaptá-la se baseando em outros indicadores específicos de delivery:
[indicators/@recipientClickRatio]
,[indicators/@reactivity]
,[indicators/@refusedRatio]
(use o valor false para o atributo sortDesc),[indicators/@transactionRatio]
,[indicators/@totalWebPage]
,[indicators/@optOutRatio]
,[indicators/@amount]
.Agora você pode definir a entrega final. Saiba mais.