In this tutorial I will show you how to set up the script and token in Marketo so you can send emails with randomized subject lines.
Why should I add randomized subject lines to my Emails?
It might seem like an odd feature to add to your email sends, but the reason I originally added it was for a follow up email that was being automatically sent to leads that didn’t respond to the prior emails. I wanted the subject line to be random, in case the recipient would receive this campaign multiple times. I thought that adding randomized subject lines would add a nice human element to a seemingly automatic email. Since the first implementation of it, I have also added it to form and white paper auto responders. It adds a nice level of customization and freshness to people that are heavily and actively engaged with our content and product demos.
Step 1: Create a Email Script Program Token
To create the token, first go to the root of your program and then go to the My Tokens section. From there you would select the Email Script option and then name it appropriately. For more information about adding a Email Script token section to your programs check out this helpful article from Marketo.
Step 2: Edit Your Token and Add Script
After you have created your email token, double click to edit it. The code editor will come up. From there you can paste in the following code:
##creates array of random subject lines
#set($foo = [
"Meeting with your account manager",
"We would love to meet",
"Scheduling a meeting",
"How can we help?",
"Coming to a city near you…",
"Did you miss my email?",
"Following up from your request"])
##creates random int variable
#set($num = $math.random(0,7))
##picks random subject line from the array and creates a variable
#set($subjectLine = $foo[$num])
##returns the random subject line
You can see in the code example that first I created a list (or array) of possible random subject lines to pick from. You can easily replace my options and add as many of your options in this list as you like.
Next I created a random integer. The function $math.random picks between a span. In my example it will pick a random number between 0 and 7. This corresponds to the array I previously created. The number 0 corresponds to the subject line of “Meeting with your account manager” and the number 1 would correspond with “We would love to meet” and so on and so forth.
Then I created a variable ($subjectLine in my example) that is the corresponding subject line from the random number.
Finally I printed the variable so that when the token is used the token will return the random subject line.
Step 3: Add the Token to Your Email
The final step is to add the token to the subject line of your email. Once that is done, whenever your email is sent it will run the email script and pick a random subject line email from your list of options! Additionally, for more information on adding email script tokens to your email, here is Marketo’s article about it.
I hope this tutorial has helped and that you have fun with it. Let me know your thoughts!