Quantcast
Channel: Forms | Jenna Molby
Viewing all articles
Browse latest Browse all 48

How to Localize a Date Field in Marketo Using a Velocity Script

$
0
0

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.

velocity-scripting-marketo

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.

date-formatting-marketo-velocity-script

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


Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>