Adobe Campaign - Use Defined Variables in An Email

Adobe Campaign - Use Defined Variables in An Email


Navigate:
 
So in other pages, we’ve covered declaring/ setting variables in a workflow and the instance/task/event level variable options.
But now we want to use them in an email! Unfortunately it’s not as easy as just putting<%= instance.vars.myVariable %> in your email, but it’s very manageable.
💡
NOTE: This is specifically for a full delivery type action. Alert actions actually have all workflow variables exposed to them by default, but they lack a lot of the flexibility that full deliveries have.
(For example, I put this page together while working on a workflow where I wanted to send top level reporting results in an email, but also attach a CSV to the email for further analysis - which isn’t something that an Alert can do!)
 
  • Head into your workflow and make a list of all the variables you’ve created. For example, this one is instance.vars.auUnsubscribeCountMob
    • notion image
 
  • Open up your delivery template, head to Properties and then Variables. In here, add in all the variables you’ll be using in your email. It’s fine to declare them all as text type variables as they’re just going into the email copy - no additional maths/transformation needed.
notion image
  • Once you’ve declared your variables, they’ll now be available for use in the email from the “Delivery Parameters” section of the variable menu .
notion image
  • Now that you’ve inserted your variables into your email, save the email template and close it. NOW RE-OPEN IT AGAIN and check your variables. The order of the variables will likely to have changed since you saved it, so take note about what order they are in now. (Start counting from 0 for the first item in the list too, to make the next step easier).
  • From the delivery activity in your workflow, head to the “Script” tab to access the Delivery object modification script.
notion image
  • Using the list of variables you’ve made earlier and the order they are declared in the email, associate the two together using the following format.
    • delivery.variables._var[<NUMBER>].stringValue = <VARIABLE> ;
      The <NUMBER> section relates to the order that the email variables are set up - the items are zero indexed, so the first item in the list is var[0].
      The <VARIABLE> section is replaced with the variable from the workflow which matches up with the email variable.
Now test it out! You should see the variables in your email being replaced with the workflow variables.