Harish Gupta

Marketo Email Scripting

Blog Post created by Harish Gupta on Jan 5, 2020

Email scripting in Marketo allows you to apply advanced logic to your Marketo emails that can’t be done with snippets or dynamic content.

Here are the few examples which show in which scenarios you can use Email scripting

  • Capitalize First Letter of the Lead’s First Name: This will capitalize 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.
  • Greetings 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.

Few eg. of Email Scripting:

Get the current date:

  • #set ($nowDate = $date.format('yyyy-MM-dd',$date))

Read the custom object value and generate the email body dynamically:

#if(${lead.eligibleForPromocode}=="false")

<table cellspacing="0" cellpadding="0" border="0" width="100%"> 

<tbody> 

#foreach( $object in $Custom_cList )  

<tr>

<td style="font-family: 'Nunito Sans', Arial; font-size: 16px; line-height: 24px; color: #2d323d;"> <a href="https://www.google.com"> $object.fieldinCustomObject</a></td>

</tr>

#end

#end

Set the URL and add token in the url

#set ($pUrl = "http://abc.com"+$object.UTMSource+"?email=${lead.Email}&firstName=${lead.FirstName}&lastName=${lead.LastName}&cid=marketo")

To get the substring from the url:

#set($fullURL = $object.URL)

#set ($index = $fullURL.indexOf('#'))

#set ($first_url= $fullURL.substring(0, $index))

#set ($second_url= $fullURL.substring($index))

Outcomes