4 Examples of Velocity Email Scripting in Marketo


Marketo’s velocity email scripting language allows you to create highly personalized emails, based on field values in your Marketo database. The scripting language can be used as a token within emails and as an alternative to Marketo’s dynamic content feature. Here are 4 examples of how you can use velocity scripts for more personalized Marketo emails.

Creating Velocity Scripts

Velocity scripts are created within a token under marketing activities inside a program or a folder.




Capitalize First Letter of the Lead’s First Name

This will captitalize the first letter of the lead’s first name, even if the value in the Marketo database is lowercase.

Hide First Name Salutation if the First Name Field is Empty

Hide the first name salutation if the first name field is empty using this script.

Greeting Based on Gender

Change the greeting in an email to Ms or Mr based on the lead’s gender.

Display Different Text Based on a Field Value

Display different text in an email based on a field value. This can be a little bit easier than setting up dynamic content, since you don’t have to create segmentation rules.


Email me, send me a tweet @jennamolby, or leave a comment

Related Posts

  • 24/05/2017
    8 Tips for Creating Marketo 2.0 Email Templates From Scratch

    Over the past couple of months, I have been creating email templates using the new(ish) email template syntax in Marketo and I’ve learned a couple tricks along the way. To save you from some headaches, here are 8 tips that I’ve learned from creating Marketo 2.0 email templates from scratch.

  • 03/10/2016
    How to Create Marketo 2.0 Email Templates

    The new Marketo email editor allows for more customizations than ever before. You now have the ability to create modules, color pickers, number variables and more, but your email templates need to follow the email template 2.0 syntax in order to take advantage of these features. In this tutorial, I’ll show you how to create a Marketo 2.0 friendly template and how to turn your existing 1.0 email templates to 2.0 email templates.

  • 06/07/2016
    10 Things You Should Know About The New Marketo Email Editor

    Marketo recently rolled out a new email editor, also referred to as the Email Editor 2.0, for their Spring ’16 release. This highly anticipated feature allows for a better experience when editing and creating emails within Marketo. However, there are a couple things you should know before enabling the new email editor. Here are 10 things you should know about the new Marketo email editor.

6 comment(s)
  • Koushik Saha

    07/07/2016 at 2:47 pm

    I'm a Salesforce developer and using velocity script for the first time! This post is really useful. I have a different use case though. I want to show specific field value from a Salesforce Custom object record (which is linked to Salesforce Contact/Marketo lead) in the email body. It works if the Lead has only one related custom object record (Onboard__cList has only one element) but doesn't work if there are multiple. #set($foo = $Onboard__cList.get(0).IC_Name__c) $foo

  • Devin Leshin

    30/06/2016 at 7:14 am

    I am a novice to all of the Velocity scripting but I used the hide the first name if empty script and had to modify it slightly to work. I changed this: #set ($fname = ${lead.FirstName}) #if($fname.equals("")) #else Hello ${lead.FirstName}), #end to this: #set ($fname = ${lead.FirstName}) #if($fname.equals("")) #else Hello ${lead.FirstName}, #end Had to lose the ) after the else's lead.FirstName. Also, how would I combine the hiding the first name and the capitalization of the first name? That would be handy, I would imagine. Thank you for writing this!

    • Devin Leshin
      to Devin Leshin

      30/06/2016 at 7:15 am

      Sorry, Blog formatted that a bit awkwardly. Basically change Hello ${lead.FirstName}), to Hello ${lead.FirstName},

  • Danny T.

    13/06/2016 at 10:37 am

    This is a really great post. Thanks a bunch for the pointers. There's a weird issue that I noticed occurring where if I use the "capitalize first name" script, it gives me an unwanted space after the lead's first name. So it would look like this: Hello Name , Have you noticed this before?

    • Jenna Molby
      to Danny T.

      13/06/2016 at 12:21 pm

      Hi Danny, Glad you like the post! Yes, I've seen that before. Is the comma in the email or in the script? I found that if you put the comma in the script there's no space after it, for example: Hello $display.capitalize($fname), Let me know if that works for you.

    • Danny T.
      to Jenna Molby

      13/06/2016 at 2:32 pm

      Hey Jenna, I swear Marketo can be so strange sometimes. I tried your suggestion earlier and it removed the comma from the token and email. Although I might have forgotten to save it... Either way, it looks good now! Thanks so much!

Leave A Comment

Your email address will not be published. Required fields are marked *

About Me

I am a results focused marketing automation expert, with a strong background in design and development. With a high level computer science background, I have the unique ability to design, code and understand data, while utilizing this skillset to further enhance my value and ROI in the digital marketing space.

Most Commented
Popular Posts