Marketo Velocity Script Error While Changing CTA Link Based on Lead Country
Hi everyone,
I have a requirement where the email content remains the same, but the CTA link needs to change dynamically based on the lead's country using a Velocity Script in Marketo.
However, I'm getting an error when I deploy the campaign.
Requirement:
- Same email template for all recipients.
- Change only the CTA URL based on the lead's country.
- Example:
- US → www.youtube.com
- Canada → https://example.com/ca
- India → https://example.com/in
Behavior:
- ✅ Email Preview: Works as expected.
-

- ❌ Smart Campaign Send: Fails with a Velocity Script error.
Velocity Script:
#set($country = ${lead.Country})
#set($url = "www.google.com")
#if($country == "India")
#set($url = "example.com/in")
#elseif($country == "United States")
#set($url = "www.youtube.com ")
#elseif($country == "Canada")
#set($url = "example.com/ca")
#else
#set($url = "www.google.com")
#end
${url}
HTML:
<td valign="top" align="center" style="text-align: center; padding: 12px 20px; color: #1570EF; font-size: 16px; font-family:Arial; font-weight: bold;background-color: #FFFFFF;" bgcolor="#FFFFFF;"> <span class="mktoText" id="text" mktoname="text" style="color:#1570EF; background-color:#FFFFFF; text-decoration: none !important;"><p><a href="https://{{my.urlcountry}}" target="_blank" style="text-decoration: none !important; color: #1570ef;" data-bipfieldlink="Text-12" data-=""><strong style="text-decoration: none;" data-bipfieldid="Text-12" data-bipfieldlabel="Banner CTA">${CtaText}</strong></a></p></span> </td>
Error:

Has anyone encountered this issue before? Am I missing something in the Velocity syntax, or is there a better approach for dynamically changing CTA links based on the lead's country?
Any help or suggestions would be greatly appreciated. Thank you!