Add instance.id to winner of AB test

Avatar

Avatar

alistairk396804

Avatar

alistairk396804

alistairk396804

22-03-2017

Hi,

I need to add the instance.id to the winning delivery in an AB test.

As advised in a different topic I need to modify the Adobe Campaign Documentation script in order to add the instance.id in so that I can identify all deliveries in a campaign by querying the instance.id. Currently the script only links the winning delivery to the operation.

My issue is I'm not sure where the instance id is held. Would the below work?

delivery.[@workflow-id] = winner.@["instance-id"]

 

This is Vipul's comment;

The Campaign documentation explaining the script for selecting winner delivery just duplicates one of the A or B delivery and assigns the operation-id to it. In other words, the winner delivery is only being linked with the campaign. You'll have to add another line to this code so that attribute [@workflow-id] is populated with instance.id and then it will get picked by your queryDef.'

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

alistairk396804

Avatar

alistairk396804

alistairk396804

22-03-2017

So this appears to work;

delivery.workflow.id = instance.id

 

For reference here is the whole 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]"/> </select> <where> <condition expr={"@FCP=0 and [@workflow-id]= " + instance.id}/> </where> <orderBy> <node expr="[indicators/@recipientClickRatio]" 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 'winner' to the delivery label delivery.label = winner.@label + "_winner" // 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"] // add instance id to winning delivery so all deliveries linked to an instance // can be queried delivery.workflow.id = instance.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

Answers (0)