Velocity Link Tracking Issue | Community
Skip to main content
April 23, 2018
Question

Velocity Link Tracking Issue

  • April 23, 2018
  • 2 replies
  • 4360 views

I have created a script that displays specific content for a user based on specific characteristics (I use email address in this simplified example). However, I am unable to track the links created in this script. Knowing that this is quite tricky in velocity, I followed all the instructions I could find but somehow it still doesn't work. Does anyone know how to fix this?

I listed both versions of my script below, as I thought maybe having the links in the if-logic (version 1) broke the tracking, but version 2 didn't work either.

Version 2:

#if($lead.Email == "myemail@mail.com")

     #set ($link = 'www.marketo.com')

     #set ($image = 'image.png')

     #set ($header = 'Title')

     #set ($text = 'Text text text.')

     #set ($button = 'Click here')

#else

     #set ($link = 'nope')

     #set ($image = 'nope')

     #set ($header = 'nope')

     #set ($text = 'nope')

     #set ($button = 'nope')

#end

<html>

<table>

<tbody>

<tr>

<td style="padding: 10px; text-align: center;"><a href="${link}" target="_blank"> <img src="ww2.mendix.com/rs/729-ZYH-434/images/${image}" width="379" border="0" class="fluid" style="height: auto;" /> </a></td>

</tr>

<tr>

<td style="padding: 16px 24px; text-align: left;" class="center-on-narrow">

<h2 style="margin-top: 0; font-size: 24px; line-height: 145%; font-weight: 300; color: #424242;">${header}</h2>

<p style="font-size: 16px; line-height: 170%; font-weight: 300; color: #424242;">

${text}

<br /></p>

</td>

</tr>

<tr>

<td style="padding: 0 24px 0 24px;">

<table border="0" cellpadding="0" cellspacing="0" align="center">

<tbody>

<tr>

<td align="center" bgcolor="#67ca39" style="-moz-border-radius: 500px; -webkit-border-radius: 500px; border-radius: 500px;"><a href="${link}" style="padding: 16px 52px; display: block; text-decoration: none; border: 1px solid #67ca39; text-align: center; font-weight: 300; font-size: 16px; font-family: sans-serif; color: #ffffff; background: #67ca39; -moz-border-radius: 500px; -webkit-border-radius: 500px; border-radius: 500px; line-height: 17px;" class="button pointerCursor"> ${button} </a></td>

</tr>

</tbody>

</table>

</td>

</tr>

</tbody>

</table>

</html>

Version 1

#if($lead.Email == "myemail@mail.com")

<html>

see code above, but with hardcoded $variables (i.e. html code for every if or else possibilities).

</html>

#else

<html>

see code above, but with hardcoded $variables (i.e. html code for every if or else possibilities).

</html>

Update: I have also tried using alternatives to #set, such as #define didn't work, also replacing $link with $url had no effect. No urls at all in velocity scripts seem to be converted to trackable links.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
Level 10
April 23, 2018

$link is a reserved word in Velocity, though I don't think that's your problem here.

There's nothing else notably wrong with your approach. The problems with tracking VTL-emitted links come when you reuse the same variable name in a loop, which you aren't doing here, and I don't have a problem when I plug in your code.

How are you testing? Are you using a Send Sample (don't do this, use a real email!) and what are the exact results you're seeing in the received email?

April 24, 2018

I'm testing with actual emails in a test campaign, but the links are not converted to the tracking format (they stay exactly as i input them, so www.marketo.com instead of go.marketo.com/34ay9wh0rtihskbnhrt90).

Could it be a problem that I'm using multiple similar scripts (3) in one e-mail?

SanfordWhiteman
Level 10
April 24, 2018

Yes, if the other scripts reuse the same variables for link output.

Note there's no problem in general with using multiple Velocity tokens -- in fact, it's highly recommended and I couldn't get by without separating my logic into multiple tokens. The problem is only with links + variables and the way Marketo post-processes VTL.

Level 3
September 30, 2019

Hi,

Was this resolved? I am having similar issue.

Thanks,

Harry