SOLVED

How to utilize tokens for email translations?

Go to solution
Alex_Gladding
Level 2

I have heard people mention using tokens to translate emails instead of using the "dynamic" email functionality. How do you utilize tokens to do this? I have not found any documentation / guides on this subject. 

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

In a nutshell:

  • You set up a common Velocity token with your translation map, let's call it $translatedText.. (Obvs. the linguistic part doesn't happen automatically!)
#set( $translatedText = {
"subjectLine" : {
"en-us" : "... something...",
"es-mx" : "... algo... "
},
"footerText" : {
"en-us" : "... something...",
"es-mx" : "... algo... "
}
} )‍‍‍‍‍‍‍‍‍‍

  • You store the lead's preferred language in a lead field, let's call it $lead.PreferredLanguage.
  • Tokens output the appropriate value from the map, like
${translatedText["subjectLine"][$lead.PreferredLanguage]}

View solution in original post

14 REPLIES 14
Alex_Gladding
Level 2

Hi Sanford, thanks for the detailed answer! This is very helpful. 

Just so I understand, so the translation map gets stored in an email script token name something like {{my.translatedText}}, and then the outputs would be stored in separate email script tokens named something like {{my.subjectLine}} or {{my.footerText}}?

Or does the entirety of the script get stored in a single email script token? And if so, how is the correct token referred to in the email?

Alex_Gladding
Level 2

I apologize in advanced as I am VERY new to this. This is how I have it set up right now. I have a email script token named {{my.translatedText}} that looks like the following. 

 

pastedImage_1.png

And then I have another email script token named {{my.subjectLine}} that looks like this...

pastedImage_2.png

And then I use refer to {{my.subjectLine}} within the emails subject line. 

SanfordWhiteman
Level 10 - Community Moderator

That's right!

You simply include both tokens in your email, with the translations map coming first.

Alex_Gladding
Level 2

Thanks Sanford! 

Its currently not working for me, but I believe its probably a referencing issue within the email itself. When you say "include both tokens in your email, with the translations map coming first", can you give me an example of what that would look like in the subject line?

Currently I just have {{my.subjectLine}} by itself in the subject line. Where and how to I add the translation map reference?

SanfordWhiteman
Level 10 - Community Moderator
Currently I just have {{my.subjectLine}} by itself in the subject line. Where and how to I add the translation map reference?

Right before it.

Alex_Gladding
Level 2

Like this? 

{{my.translatedText:default=edit me}}{{my.subjectLine:default=edit me}}

It returns the content of the email script:

pastedImage_1.png

SanfordWhiteman
Level 10 - Community Moderator
{{my.translatedText:default=edit me}}{{my.subjectLine:default=edit me}}

Almost, but not with the defaults, those do not work with Velocity tokens:

   {{my.translatedText}}{{my.subjectLine}}


pastedImage_1.png

Make sure:

  • you're previewing by List (preferred) or Lead, not Default
  • you've checked the checkbox for the Country field in Script Editor for the {{my.translatedText}} token (you don't have to check it for both tokens, just the first)
Alex_Gladding
Level 2

Worked!!! I just needed to check the Country field. This is awesome

Thanks so much for your help, Sanford!

SanfordWhiteman
Level 10 - Community Moderator

Great!

Broderick_Klem1
Level 4

Hey @SanfordWhiteman, we are wanting to use a similar approach, but how would we structure the "translatedText" token if we're wanting to use a "contains" instead of "is" for our language field? We use "lead.browserLanguage" as our way of defining which language they get and they contain things like "es-LA" or "es-Pt", etc. So in that case I'd want the map to say something like "if contains "es" then: [Spanish translation]

SanfordWhiteman
Level 10 - Community Moderator

Sounds like startsWith, not contains! Otherwise a lot of confusion will ensue.

 

The token with the translations would be structured the same. The token that finds the current translation couldn't just grab the matching property, though. It has to loop (#foreach) over the entries and then use startsWith.

Nick_Deboo
Level 1

First of all, this topic is amazing! This community can't thank @SanfordWhiteman enough!

 

I've been playing with this for some time and stumble upon one problem. I have a CTAText and CTAURL that's translated but Marketo doesn't track it. However, when I have an URL with <a> tag in the velocity script, it does track it. The problem is that in our email designs, a-tags often include inline styling and we definitely don't want that in our velocity script.

 

Anyone ideas?

Michael_Florin
Level 10

No idea here. (See also - if you haven't already - https://nation.marketo.com/t5/product-discussions/velocity-script-a-trackable-url/td-p/164640)

 

I had built a 30 email trial nurture in 6 languages completely in Velocity once, and it was okay, but eventually I'd not do it again. Next time I'd go traditionally with Snippets and Segmentations.

SanfordWhiteman
Level 10 - Community Moderator

In a nutshell:

  • You set up a common Velocity token with your translation map, let's call it $translatedText.. (Obvs. the linguistic part doesn't happen automatically!)
#set( $translatedText = {
"subjectLine" : {
"en-us" : "... something...",
"es-mx" : "... algo... "
},
"footerText" : {
"en-us" : "... something...",
"es-mx" : "... algo... "
}
} )‍‍‍‍‍‍‍‍‍‍

  • You store the lead's preferred language in a lead field, let's call it $lead.PreferredLanguage.
  • Tokens output the appropriate value from the map, like
${translatedText["subjectLine"][$lead.PreferredLanguage]}