Email Scripting for subject personalization? | Community
Skip to main content
May 26, 2015
Solved

Email Scripting for subject personalization?

  • May 26, 2015
  • 2 replies
  • 3998 views

We're hoping to have a subject line like this (just as an example, not an actual subject):

"Thanks for coming, Customer. Hope to see you next time"

However about 10% of our lists is missing a first name. There isn't really a good default to put in for this, so we'd like to leave it off instead. The only issue is the punctuation. Having the comma means it could read: "Thanks for coming, ." which we don't want. I was looking in to email scripting for this, but the documentation seems scarce, and from an older version of Marketo.

Is there a good way of doing this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Neil_Robertson6

I think in either case you will want to check the length of the value before outputting it so you do not get a strange output.

Also - just so you are aware you can combine multiple logic blocks to (AND/OR) things should you need to thus (this is just for demo re: Velocity as I wouldn't recommend doing it this way!! this is just to show you the OR function via the double pipe ||)

#set ($lengthTest = ${lead.FirstName})

#if ( $lengthTest.length() == 1 ||  $lengthTest.length() == 2)

"Thanks for coming, Single Letter or two letter Customer. Hope to see you next time"

#elseif ($lead.usageLanguagePreference <1)

"Thanks for coming,  Customer . Hope to see you next time"

#else

"Thanks for coming,  ${lead.FirstName}. Hope to see you next time"

#end

2 replies

Neil_Robertson6
Level 4
May 26, 2015

You will need to do this via Velocity Script.  Should be fairly simple as a program token. 

try this:

#set ($lengthTest = ${lead.FirstName})

#if ( $lengthTest.length() <= 1 )

"Thanks for coming, Customer. Hope to see you next time"

#else

"Thanks for coming,  ${lead.FirstName}. Hope to see you next time"

#end

NOTE: the -1 is just to ensure that you are checking for names with only 1 char which is rare. You could easily just change that to Zero.  Add this as an Email script Token and then insert using {{my.YOURTOKENNAME}} and you should be good to go.

SanfordWhiteman
Level 10
May 26, 2015

Nice one!

(But I don't really agree that a First Name with one char is untrustworthy. More likely, the salesperson was working too quickly and didn't catch the full name, or the lead her/himself just put the initial in a form, but I'd still rather call them "S. Whiteman" than "Whiteman.")

Neil_Robertson6
Neil_Robertson6Accepted solution
Level 4
May 26, 2015

I think in either case you will want to check the length of the value before outputting it so you do not get a strange output.

Also - just so you are aware you can combine multiple logic blocks to (AND/OR) things should you need to thus (this is just for demo re: Velocity as I wouldn't recommend doing it this way!! this is just to show you the OR function via the double pipe ||)

#set ($lengthTest = ${lead.FirstName})

#if ( $lengthTest.length() == 1 ||  $lengthTest.length() == 2)

"Thanks for coming, Single Letter or two letter Customer. Hope to see you next time"

#elseif ($lead.usageLanguagePreference <1)

"Thanks for coming,  Customer . Hope to see you next time"

#else

"Thanks for coming,  ${lead.FirstName}. Hope to see you next time"

#end

May 26, 2015

This is great! In this instance, the subject line would be referring to the first name only, so checking for one letter is a great idea. I'll need to try this out when I'm back in the office next. Thanks!

Neil_Robertson6
Level 4
May 26, 2015

Np - happy to help. Also be wary that Velocity script tokens CANNOT be used in dynamic content / emails via Marketo Segmentations.  It is pretty much only for standard/static style programs.

May 27, 2015

Interesting and good to know as we do a lot of our emails segmented. If we did a segmented email with a static subject line, for example, could we use an email scripted token in the subject line? Or just not in the sections/blocks that have been segmented?