SOLVED

Velocity token: traceable links fail, but work if non traceable

Go to solution
Grégoire_Miche2
Level 10

Velocity token: traceable links fail, but work if non traceable

Dear all,

we have the following code in a velocity token:

#set($downloadLink={

  "BPDCS":{

  "title":"BPD Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-bpd-digitalisation-marketing-systeme-information-marketing-commercial.pdf"

  },

  "DACS":{

  "title":"Deny All Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-denyall-marketing-automation.pdf"

  },

    "IVCS":{

  "title":"Infovista Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-infovista-systeme-information-marketing.pdf"

  },

  "EBSCS":{

  "title":"ESSEC Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-essec-conception-deploiement-strategie-acquisition-nurturing.pdf"

  },

  "KDSCS":{

  "title":"KDS Case Study",

  "link":"infos.inficiences.com/rs/593-IYJ-660/images/Inficiencespartners-casestudy-kds-nouvelles-pratiques-generation-demande-automatisee.pdf"

  }

})

<ul>

#foreach ($key in $lead.downloadcenter.split("[;]"))

#set ($key = ${key.trim()})

      <li><a href="http://${downloadLink.get($key).link}" target="_blank" class="mktNoTrack">$downloadLink.get($key).title</a></li>

#end

</ul>

It works well. But if we remove the class="mktNoTrack" from the <a> tag, the links generated raise a DNS error:

pastedImage_4.png

any hint ?

-Greg

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token: traceable links fail, but work if non traceable

22 REPLIES 22
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token: traceable links fail, but work if non traceable

Let's reduce the problem surface. Does this happen if only a single <a> is output?

Grégoire_Miche2
Level 10

Re: Velocity token: traceable links fail, but work if non traceable

Hi Sanford,

<a href="http://${downloadLink.get($key).link}" target="_blank">$downloadLink.get($key).title</a>

Will raise the error, showing that the ${downloadLink.get($key).link} is apparently not resolved in the script. I also have tried to add a dummy class (class="whatever"), but the error remains.

<a href="http://${downloadLink.get($key).link}" target="_blank" class="mktNoTrack">$downloadLink.get($key).title</a>

Works perfectly well.

http://${downloadLink.get($key).link}

Works well, displaying the plain URL in the email.

I have set up a test program that can be fired here: Download Center Test-inficiences the email will have the 3 links

This seems to me like a bug.

-Greg

Steven_Vanderb3
Marketo Employee

Re: Velocity token: traceable links fail, but work if non traceable

Are you following what's at the bottom of this doc? http://developers.marketo.com/email-scripting/   Link tracking doesn't work in a foreach loop which I think is what you have your links printing in if I'm reading it correctly.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token: traceable links fail, but work if non traceable

AFAIK not so much the #foreach as the final output containing multiple links and wrapping in <li>s (that's why I asked Greg to reduce it to 1).

This is known behavior that I posted a workaround for before...

Grégoire_Miche2
Level 10

Re: Velocity token: traceable links fail, but work if non traceable

Hi Sanford,

I do not know what would be the outcome if we changed the code, but if we select only 1 doc in the form, we get only 1 <a> and it still breaks. But it still goes through the loop.

My velocity skills are not good enough to be able to change the code so that only the first value is used outside of the look.

-Greg

Grégoire_Miche2
Level 10

Re: Velocity token: traceable links fail, but work if non traceable

This is what I read in the doc:

To ensure proper parsing of URLs, the whole path should be set as a variable and then printed, and variable should not be printed inside of URL references.  The  protocol(http:// or https://) must be included and must be separate from the rest of the URL.

Which is why in the code reads

href="http://${downloadLink.get($key).link}"

and indeed:

Links will not be tracked if they are outputted from within a for or foreach loop.

but for the moment, it does not seem to be a tracking problem, but rather than the {downloadLink.get($key).link} is not rendering. Now, if the loop is the issue, then I suppose I will have no choice but use a webhook to create the list of links, send it back to a field and output it directly in the email.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token: traceable links fail, but work if non traceable

I've got your solution -- just wait up a bit..

Grégoire_Miche2
Level 10

Re: Velocity token: traceable links fail, but work if non traceable

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity token: traceable links fail, but work if non traceable