SOLVED

Email Tracking not working on velocity token

Go to solution
Maria_Zonk
Level 2

Email Tracking not working on velocity token

Hi, 

I have successfully created links using tokens that are trackable. 

However, this time I have a custom object with url link. 

I have tried multiple coding and either the link gets broken when mkto is adding the tracking token or the link works but the tracking token is not being added.  

Any tips/insights would be great! thanks!

 

Token1 - link gets broken when mkto token is being added. when tested $prodlinktrim on its own the syntax is as expected.  

 

#if(!$productRecommendation_cList.isEmpty())
#foreach($item in $productRecommendation_cList)
#set($Prodlink=$item.rec_productLink)
#set($Prodlinktrim=$Prodlink.replaceAll("^https://",""))
#if($item.rec_rank=="1")<a href="https://$Prodlinktrim">link text</a>
#else
#end
#end
#end

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email Tracking not working on velocity token

How about adding a set of curly braces around the variable where you're emitting its value in the anchor tag? 

 

I made a couple of changes and added comments in the script below FYR.

 

#if(!$productRecommendation_cList.isEmpty())
#foreach($item in $productRecommendation_cList)
#if($item.rec_rank.equals("1")) ##In general, equals() function is better than "==" operator
#set($Prodlink=$item.rec_productLink.replaceAll("^https://",""))
<a href="https://${Prodlink}">link text</a> ##Try using {} around the $Prodlink
#else ## You can remove else block if you don't intend to add anything in it.
#end
#end
#end

 

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Tracking not working on velocity token

You can’t output multiple tracked links using the same reference. Is it the case here that there’s no more than one matching item? What is the exact way that the link is “broken”?

Maria_Zonk
Level 2

Re: Email Tracking not working on velocity token

Hi Sanford, 

There is only one link that meets the criteria rec_rank=="1".

We are currently using the code below which creates the right url but the clicks are not being tracked as the HTTPS is inside the token. 

#if(!$productRecommendation_cList.isEmpty())
#foreach($item in $productRecommendation_cList)
#set($Prodlink=$item.rec_productLink)

#if($item.rec_rank=="1")$Prodlink
#else#end#end#end

 

When I change the code to the one in my initial post the url is ok when I hover over the link in the Marketo email preview. However, once I trigger a test email the link doesn't work. 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email Tracking not working on velocity token

How about adding a set of curly braces around the variable where you're emitting its value in the anchor tag? 

 

I made a couple of changes and added comments in the script below FYR.

 

#if(!$productRecommendation_cList.isEmpty())
#foreach($item in $productRecommendation_cList)
#if($item.rec_rank.equals("1")) ##In general, equals() function is better than "==" operator
#set($Prodlink=$item.rec_productLink.replaceAll("^https://",""))
<a href="https://${Prodlink}">link text</a> ##Try using {} around the $Prodlink
#else ## You can remove else block if you don't intend to add anything in it.
#end
#end
#end

 

Maria_Zonk
Level 2

Re: Email Tracking not working on velocity token

Hi Thanks so much, 

I tested the changes and the link works but the Marketo tracking token doesn't get added to the url

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email Tracking not working on velocity token

Well, this script works well in my instance! Given that there is not more than 1 matching item for a person, and hence you're only using the local variable's reference to output only a single URL, it should ideally work as expected. If you've already not, could you please try sending an email to a test lead using the send email flow step instead of sending a test sample?