Personalization via Velocity Scripting
Used Marketo Velocity scripting to create hyper-specific personalization based on user account data. Fill out the form below and watch the email content change instantly. Try the sample values shown in each field to see how different metrics affect customer health.
Edit Values
The Challenge
At ActivTrak, we needed to send highly personalized productivity benchmark emails to customers based on their unique account data. Each customer received their unique account data, and the messaging needed to adapt based on whether their metrics fell within healthy ranges, required monitoring, or needed immediate action.
Creating individual email versions for every possible combination would have been impossible to maintain. We needed a dynamic solution that could:
- Process complex data inputs (time strings, numerical ranges)
- Apply conditional logic to determine messaging
- Generate personalized content blocks dynamically
- Maintain consistency across thousands of recipients
- Scale efficiently without manual intervention
The Solution
I developed a comprehensive Velocity scripting solution that automated the entire personalization process. The script handles data parsing, conditional logic, and dynamic content generation, all within the email program.
Conditional Logic
Implemented multi-tier logic that evaluates metrics against benchmarks and determines appropriate messaging (success, warning, or action required).
Data Parsing
Built custom functions to parse time strings (like "8h 18m") into usable formats for calculations and comparisons.
Dynamic Content
Generated personalized titles, colors, and messages based on each customer's specific data patterns.
Fallback Handling
Implemented robust error handling and smart list filters to ensure emails rendered correctly when data was missing or fell outside of expected values.
Code Examples
Here's a look at the core Velocity scripting logic that powers the personalization:
Time Parsing Function
## Parse time string (e.g., "8h 18m" or "44m") into minutes
#set($timeString = $lead.collaborationTime2025)
#if($timeString.contains("h"))
#set($parts = $timeString.split("h"))
#set($hours = $convert.toInteger($parts[0].trim()))
#set($minutes = 0)
#if($parts.size() > 1 && $parts[1] && $parts[1].trim() != "")
#set($minutesPart = $parts[1].replace("m","").trim())
#if($minutesPart != "")
#set($minutes = $convert.toInteger($minutesPart))
#end
#end
#set($value = ($hours * 60) + $minutes)
#else
#set($minutesPart = $timeString.replace("m","").trim())
#set($value = $convert.toInteger($minutesPart))
#endConditional Logic Example
## Process Collaboration Time with conditional messaging
#if($value >= 30 && $value <= 60)
<p><strong style="color: #2ED4B5;">Congrats!</strong>
Your collaboration time closely matches the benchmark...</p>
#elseif($value > 60 && $value <= 90)
<p><strong style="color: #FBD13E;">Keep an eye on this.</strong>
Collaboration time is higher than the benchmark...</p>
#else
<p><strong style="color: #FF864B;">This may call for action.</strong>
Collaboration time requires immediate attention...</p>
#endDynamic Content Token
## Token usage in email template
<table>
<tr>
<td>
{{my.Collaboration Time Content}}
</td>
</tr>
<tr>
<td>
{{my.Focus Time Content}}
</td>
</tr>
</table>