Stepping away from the technical aspects of what you're doing, and into the softer 'personalisation' side.....
The problem with your approach to showing 'Hi Member' for someone with two characters in their name is that people have two letter names.
Me for example.
Ty Cobb, Al Sharpton, Ed Asner being others.
Why presume that a two character name is invalid?
Agreed, 2-character names are quite possible... never seen evidence that 2-character false names are more common than 2-character real names.
Hi @Jo_Pitts1 ,
CC : @SanfordWhiteman
It is a really good point actually. So, in our database, we have noticed names like Aa, Ab, Bb etc so which is why we thought to display 'Hi Member' But yeah there could be a missed opportunity for good data as well like you mentioned.
So, I am thinking to add a condition of comparing first two chars using substring method and if it is same then display 'Hi Member' else display their name.
Kind Regards,
Vidhi
So, I am thinking to add a condition of comparing first two chars using substring
Use a regex
#if( $lead.field.matches("(?i)(.)\1") )
Hi @Jo_Pitts1 & @SanfordWhiteman
Thank you for all your inputs.
I just had one more thought. Is there a way to capture Subject line text in a token and then capitalize the first word of the subject line if it is not.
We want to display <Name>, < Lower case of first word in Subject Line Text> in case of happy world scenarios for us.
else,
we want to display just the subject line with first word capitalized.
Example:
Name is Ed
Ed, our latest news and articles
Name is : A
Our latest news and articles
How do we capture the subject line value if we can using velocity or any other method.
There is an alternative solution but with that if someone is using that token then they will have to tweak the token to add the capitalized subject line in that condition. That can result in error if that user is not aware of scripting, which is why trying to find the automate solution.
Kind Regards,
Vidhi
You would have to have a Velocity token in the Subject. There's no way to backtrack and change Subject data once the body is being parsed.
It's a new token but the logic is effectively the same, if I understand correctly.
The output would be different, but the logic to check whether it's a valid name is the same. Just make sure your entire subject line is in that token - don't have the token only output the name, then have the rest as free text.
HI @Phillip_Wild ,
Actually like @SanfordWhiteman assisted with his inputs about the subject line rendering, I believe my case falls in that category.
I understand your point but I was trying to automate the first word of the subject line free text by reading the text via any means in script and in case it is not a valid name, the token will display blank( which is fine) however, I wanted that the free text's first word will also be capitalized.
But since, we cannot parse the subject line data once the body is being parsed, I am afraid we can do this automation with scripting.
Kind Regards,
Vidhi
you can include the same logic around first name in your subject like token.
There are probably better ways of doing this, but this will work.
#set ($subjectLine = 'this is my subject line')
#set ($firstName = ${lead.FirstName.toLowerCase()})
#if( $firstName.matches("(?i)(.)\1") )
$display.capitalize($subjectLine)
#else
$display.capitalize($firstName), ${subjectLine}
#end
So, I guess you can't just have someone enter in a subject line, and retroactively change it, but you can have a token containing the subject line and get the outcome you want.
I've tested this a bit further, and you can separate it into two tokens, which gets you closer to where you want to be.
Set the subject line:
Put a token containing this at the top of your email body. It is easy for non technical people to edit, and could even be extended to look at segment data etc. to create a dynamic subject line
#set ($subjectLine = 'this is my subject line')
Emit the subject line:
place a token containing this code in your subject line
#set ($firstName = ${lead.FirstName.toLowerCase()})
#if( $firstName.matches("(?i)(.)\1") )
$display.capitalize($subjectLine)
#else
$display.capitalize($firstName), ${subjectLine}
#end
There is something to learn from that BTW - Marketo processes tokens in the email body BEFORE it processes tokens in the subject line. If it did it the other way around (subject before body), the separated approach wouldn't work.
I think that is as close as you're going to get.
Cheers
Jo