I'm setting a program where a customer, upon filling out a form (that has selections to 6 contents - checkboxes), the customer will receive one email containing the contents selected.
For example, the customer selected 3 out of 6 available contents on the form checkboxes > triggers a 'confirmation email' > the customer will receive one confirmation email that contains 3 different content URLs based on the form selection.
Is this possible and if it is, how do I go about doing this? I've tried searching for solutions here and Google, found nothing so far.
Hope this makes sense.
Are the values on the form (not the displayed values next to the checkbox, but the underlying server values) the full URLs?
Hi Sanford
No, it's not the full URLs - can I insert full URLs in the values? I've never tried that.
Does that mean if I insert the full URLs in the values, I can just insert the token into the confirmation email and it will display the checked item?
No, it's not the full URLs - can I insert full URLs in the values? I've never tried that.
I don't actually recommend it as it makes the setup significantly harder to maintain. Was just checking to see if you needed a separate map of names to URLs (which you do).
If the name of your field were Last Selected Documents then you'd use a Velocity (Email Script) token like this:
#set( $documentNameToURLMap = {
"apple" : "www.example.com/apple.pdf",
"pear" : "www.example.com/pear.xls",
"pumpkin" : "www.example.com/pumpkin.doc",
"orange" : "www.example.com/orange.jpg"
} )
#set( $documentNameList = $lead.LastSelectedDocuments )
## --- No need to edit below this line! ---
#if( !$documentNameList.isEmpty() )
Click for each document:<br>
#foreach( $name in $documentNameList.split(";\s*") )
<a href="https://${documentNameToURLMap[$name]}">$name</a>
#end
#end
As you can see, the first section sets up a map between each friendly name (from the form) and its corresponding URL (without the protocol).
Then it's a loop over the current values in the semicolon-delimited string (which is how Marketo always stores multi-valued fields).
Make sure to select your equivalent of Last Selected Documents from the tree on the right-hand side of Script Editor. Temporarily drag it onto the Script Editor canvas to see its Velocity name (which doesn't have spaces and isn't necessarily the same as the name you'd use in a {{lead.token}}). Then replace $lead.LastSelectedDocuments in the code (line #07) with that appropriate field name for your instance.
Hi Sanford, it worked!
But I think I messed up the scripting - This is what I input:
#set( $documentNameToURLMap = {
"Report1" : "www.example.com/apple.pdf",
"Report2" : "www.example.com/pear.xls",
"Report3" : "www.example.com/pumpkin.doc"
} )
#set( $documentNameList = ${lead.testCustom} )
#if( !$documentNameList.isEmpty() )
Click for each document:<br>
#foreach( $name in $documentNameList.split(";\s*") )
<a href="www.example.com/apple.pdf">Report1</a>
<a href="www.example.com/pear.xls">Report2</a>
<a href="www.example.com/pumpkin.doc">Report3</a>
#end
#end
I selected Report1 and Report2 but received all 3 in the email. Email screenshot below:
You should be using exact code I provided -- other than changing out the map entries and putting in your $lead.testCustom field.
Also note that the curly braces around $lead.testCustom should be removed.
Hmmm, I tried - this time it only shows below (ignore 'TOKEN')
the code i insert is:
#set( $documentNameToURLMap = {
"Report1" : "www.example.com/apple.pdf",
"Report2" : "www.example.com/pear.xls",
"Report3" : "www.example.com/pumpkin.doc"
} )
#set( $documentNameList = $lead.testCustom )
## --- No need to edit below this line! ---
#if( !$documentNameList.isEmpty() )
Click for each document:<br>
#foreach( $name in $documentNameList.split(";\s*") )
<a href="https://${documentNameToURLMap[$name]}">$name</a>
#end
#end
What's the value of $lead.testCustom for the lead you're testing with?
The code you've got now will work fine, if the field value is "Report1" or "Report2;Report3" as expected.
Also make sure you're testing using a real Send Email or with Preview By List. Not with Send Sample.
Hi @SanfordWhiteman doesn't this solution hit the same problem you provided a workaround before i.e.
https://blog.teknkl.com/multiple-marketo-tracked-links-in-velocity/
at least it seems to when I use it
Yep.