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
Solved! Go to Solution.
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
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”?
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.
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
Hi Thanks so much,
I tested the changes and the link works but the Marketo tracking token doesn't get added to the url
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?