Basic Email Scripting Examples for Marketers

Anonymous
Not applicable

I started using some email scripts about a year ago when our support for Velocity scripting was pretty new. As has no doubt become obvious by now, I’m not the most technical of consultants. (That’s why John’s on this blog.) In teaching myself how to do this, all I had to go off of was the documentation on the developer site (here), the Apache documentation (here), and trial and error.

Sadly, published examples of working email scripts for Marketo are still few and far between. So, while I cannot explain much about Velocity from the technical side, I can share some very basic email scripts that even a marketer like me can use.

If you don’t know how to properly create an email script token, you should refer to the doc here.

Example 1: Properly Capitalizing First Name

#set ($fname = ${lead.FirstName})

#if($fname.equals(""))

Friend

#else

$display.capitalize($fname)

#end

Example 2: Displaying a Greeting Based on Gender (Portuguese)

#if ( ${lead.gender} == "F" )

Cara Sra. Dra.

#else

Caro Sr. Dr.

#end

Example 3: Displaying a Greeting Based on Gender (German)

#if ( ${lead.Salutation} == "Mr." || ${lead.Salutation} == "Mr" )

Herr

#elseif ( ${lead.Salutation} == "Mrs." || ${lead.Salutation} == "Mrs" || ${lead.Salutation} == "Ms." || ${lead.Salutation} =="Ms" || ${lead.Salutation} == "Miss" )

Frau

#else

Herr

#end

Example 4: Displaying a Table with One Row for Each Sales Order for that Contact

<table border="1">

<tr>

<th>Item <th>Order ID</th><th>Date</th><th>Price</th>

</tr>

#foreach ( $SalesOrder in $SalesOrderList )

<tr>

<td>

$SalesOrder.Sales_Order_Item

</td>

<td>

$SalesOrder.Sales_Order_ID

</td>

<td>

$SalesOrder.Sales_Order_Date

</td>

<td>

$SalesOrder.Sales_Order_Price

</td>

#end

Example 5: Displaying Different Email Text in an Email Based on a Lead Field Value

#if(${lead.fieldname} == "fieldvalue1")

Email text here

#elseif (${lead.fieldname} == "fieldvalue2")

Email text here

#else

Email text here

#end

5994
9
9 Comments