Re: Using velocity script in different tracking links

API_Dev
Level 2

Using velocity script in different tracking links

Hi,

I have a velocity script that outputs a certain value (say $value = 'abc') and I want to use this value in different links as a part of url parameter string.

I have 3 links that are generated from a different token for the website's child page name. For e.g.:

link1: https://www.example.com/{{my.pagename}}/aboutus/

link2: https://www.example.com/{{my.pagename}}/​currentissues/

link3: https://www.example.com/{{my.pagename}}/upcomingposts/

And I want to use my 1 velocity token in all the above 3 urls in the email. For eg, like this:  https://www.example.com/{{my.pagename}}/aboutus/param1={{my.velocitytoken}}, https://www.example.com/{{my.pagename}}/​currentissues/param1={{my.velocitytoken}} and https://www.example.com/{{my.pagename}}/upcomingposts/param1={{my.velocitytoken}}

But I'm also aware that in order to create fully tracked links you need to output the complete url in the velocity script itself, which is not what we desire as our links are generated by already defined local tokens.

Is there work around in this case with using the velocity script tokens?

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Using velocity script in different tracking links

The problem is broader than you think.

As you say, you must output an entire <a> tag from Velocity. This doesn't mean you can't combine data from other {{my.}} tokens to create the href, inner text, etc. but it does mean they have to be Velocity {{my.}} tokens.

But when you're building multiple links you also need to pay attention to this:Multiple tracked links in Velocity

API_Dev
Level 2

Re: Using velocity script in different tracking links

So you're suggesting there is no solution?

I read your blog but the thing is these different links are already embedded in the the email template and if I try to generate all the links (approx. 15) in my velocity instead of embedded them as raw, then it will get very complicated for our current setup.

SanfordWhiteman
Level 10 - Community Moderator

Re: Using velocity script in different tracking links

I read your blog but the thing is these different links are already embedded in the the email template and if I try to generate all the links (approx. 15) in my velocity instead of embedded them as raw, then it will get very complicated for our current setup.

Well, you've made a decision that's at odds with the technical rules.

Much like switching to modules in emails, or mktoVariables in LPs, you have to change how you work to use new features.