VTL code of my.token appears in tracked link

WolframLotz
Level 4

VTL code of my.token appears in tracked link

Hi everyone, 

 

I faced a strange situation using a my.token for the href of a tracked link. For some reason marketo uses the VTL code as link target of the tracked link enstead of the code output. 

 

I'm pretty sure this worked in the past. Did one of you had the same issue?

 

Kind Regards
Wolfram

Whats the detailed situation?

We receive a personalised link via webhook. This link is stored as in data field. 

If we would use that link in our email everything would be fine. BUT the link contains the https protokoll and so it is not tracked. 

 

To fix this we created an email script token. The theorie is pretty easy .... the script token removes the 'https://' using the replace methode. The https:// protokoll is hard coded in the email and ensures that marketo will track the link. 

 

Adding this token to the email the link target url is shown correct in the preview. Is the token added as text it is rendered correct as well. As well the link tracking will be added to the a-tag. 
But after clicking the tracked link in the email you will not be redirected to the URL. Instead you can see in the console that marketo tried to forward you to the VTL-code which is (naturally) recogniced as a not valid link.

Example
{{my.Invitation-Link}} in my.tokens

#set( $urlField = $member.option1 )
#set( $urlNoProto = $urlField.replaceAll("(?i)^https?://","") )
${urlNoProto}


Use in the email

<a href="https://{{my.Invitation-Link}}">Your personal Invitation Link</a>

 
Console output in browser

WolframLotz_0-1678260364592.png

 

3 REPLIES 3
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: VTL code of my.token appears in tracked link

It's always recommended to output the entire link's HTML using the velocity script instead of outputting bare URLs and trying to plug them into <a> tag in the outer email content. Not following this practice could lead to many issues, including broken URLs with Velocity code in them (similar to your case). You should check out Sandy's blog here. Try the script below:

 

#set($urlField = $member.option1 )
#set($urlNoProto = $urlField.replaceAll("(?i)^https?://","") )
<a href="https://${urlNoProto}" target="_blank">ClickME</a>
WolframLotz
Level 4

Re: VTL code of my.token appears in tracked link

Hi @Darshil_Shah1 

Thank you. Isn't it the case that the a-tag and the https:// has to be part of the email and shouldn't be hidden in a tag to enable Marketo to track the link. 

If the whole a-tag is part of the email script token, isn't it part of a non tracked token again?  

Sandy's blog is great. But on that specific question I unfortunately did not find any answere.. 

Best Regards
Wolfram

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: VTL code of my.token appears in tracked link

Outputting the links in email from the velocity is an exception to this, when you use an email script token, you should output the entire <a> tag (not just the URL/partially formed URL, nor the full href including the protocol, but the entire <a> including closing </a> and inner content).