SOLVED

Email Scripting for subject personalization?

Go to solution
Anonymous
Not applicable

Email Scripting for subject personalization?

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Neil_Robertson6
Level 5

Re: Email Scripting for subject personalization?

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

View solution in original post

9 REPLIES 9
Neil_Robertson6
Level 5

Re: Email Scripting for subject personalization?

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 - Community Moderator

Re: Email Scripting for subject personalization?

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
Level 5

Re: Email Scripting for subject personalization?

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

Anonymous
Not applicable

Re: Email Scripting for subject personalization?

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 5

Re: Email Scripting for subject personalization?

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.

Anonymous
Not applicable

Re: Email Scripting for subject personalization?

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?

Neil_Robertson6
Level 5

Re: Email Scripting for subject personalization?

Good question. I haven't actually tried that as we weren't isn't subject line personalisation.

I may try later.

Anonymous
Not applicable

Re: Email Scripting for subject personalization?

Yes, you can use email script tokens in static sections even if other parts of the email are dynamic.

Also you could code the dynamic parts into the email script if you really wanted to have a dynamic scripted section.

Neil_Robertson6
Level 5

Re: Email Scripting for subject personalization?

Yep, that is what we had to do (add the code in the tokens)