
Earlier this month I was given the task of localizing the date formatting within a Marketo email. The email referenced a date field within Marketo that was formatted as yyyy-mm-dd. The issue was that it was a global email, sent out to different countries who do not format the date as yyyy-mm-dd. To fix this issue I created a simple velocity script to transform the date value into something that’s recognized within each country. Here’s a breakdown of how I did it and how you can implement something similar in your Marketo instance.
Creating Velocity Scripts in Marketo
Velocity scripts are created within a token under marketing activities inside a program or a folder.
Formatting the Date
Here’s an example of a velocity script that will format the data, based on Country
## Check if the Country is France or Ireland #if(${lead.Country} == "France" || ${lead.Country} == "Ireland") ## Display the date as dd-mm-yyyy $date.format('dd-MM-yyyy', ${convert.parseDate(${lead.my_date__c}, 'yyyy-MM-dd')}) ## Check if the Country is Germany #elseif(${lead.Country} == "Germany") ## Display the date as dd.mm.yyyy $date.format('dd.MM.yyyy', ${convert.parseDate(${lead.my_date__c}, 'yyyy-MM-dd')}) ## If Country equals anything else or if the Country is empty display the date in the regular default format #else ${lead.my_date__c} #end
This example checks if the Country is equal to France or Ireland and then displays the date format in dd-mm-yyyy. If the Country is Germany, then the date format is dd.mm.yyyy. If the Country is blank or any other value other than France, Ireland or Germany, then the default date format will be displayed.
The tricky part is formatting the date. Here’s an overview of what each of the values within the date velocity script means.
Testing
You can test the script using the send sample email option and selecting a lead that has a date value.
The power of velocity scripts
This is just one example of how you can use velocity scripts in your Marketo emails. Learn how you can use velocity scripts to create more personalized Marketo emails.
Questions?
Send them to me via email, send me a tweet @jennamolby, or leave a comment