SOLVED

How to track velocity script link

Go to solution
p4vankum4r88
Level 2

How to track velocity script link

Hi Team,

 

I am facing an issue in tracking a link which is coded in the velocity script. This link is generated from opportunity object, since I cannot use it directly in the email, I need a work around for it.  We thought velocity script is a work around but it is not working when the link is made trackable.

Kindly help.

 

Regards

Pavan

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Jon_Wright
Level 4

Re: How to track velocity script link

Would need more detail but sounds like potentially is related to the issue for outputting tracked links from a list. I recommend Sanford's excellent blog for all things Marketo + Velocity: https://blog.teknkl.com/multiple-marketo-tracked-links-in-velocity/

View solution in original post

13 REPLIES 13
Jon_Wright
Level 4

Re: How to track velocity script link

Would need more detail but sounds like potentially is related to the issue for outputting tracked links from a list. I recommend Sanford's excellent blog for all things Marketo + Velocity: https://blog.teknkl.com/multiple-marketo-tracked-links-in-velocity/

SanfordWhiteman
Level 10 - Community Moderator

Re: How to track velocity script link

As Jon notes, you may be running into the well-known problem with links built from multiple references to the same VTL variable.

 

But since you didn’t supply your Velocity code yet, it’s impossible to say.

p4vankum4r88
Level 2

Re: How to track velocity script link

Hi Sanford,

 

Thank you very much for taking time to reply.  

The problem is we have a personalized URL that gets generated in SFDC and we want to use it in the email. We are able to use it using velocity token but unable to track the link.

I went through your blog and tweaked your code as per my requirement but it ain't working, I even tried hardcoding it in HTML itself but even that did not work. 

 

#set( $urlField = $OpportunityList.get(0).Repayment_Personalized_URL__c )
#set( $urlNoProto = $urlField.replaceAll("(?i)^https?://","") )
#if( $urlField.matches("(?i)^http://") )
<a href="http://${urlNoProto}">Go for it</a>
#else
<a href="https://${urlNoProto}">Go for it</a>
#end

 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to track velocity script link

Please remember to highlight your code, thanks (I fixed it for you).

 


I went through your blog and tweaked your code as per my requirement but it ain't working, I even tried hardcoding it in HTML itself but even that did not work. 

#set( $urlField = $OpportunityList.get(0).Repayment_Personalized_URL__c )
#set( $urlNoProto = $urlField.replaceAll("(?i)^https?://","") )
#if( $urlField.matches("(?i)^http://") )
<a href="http://${urlNoProto}">Go for it</a>
#else
<a href="https://${urlNoProto}">Go for it</a>
#end

So you’re saying this code outputs a perfectly usable <a> tag (as it should) but the link is not rewritten to bounce off the branding domain? That’s strange indeed. What do you mean by “hardcoding it in HTML itself” exactly?

p4vankum4r88
Level 2

Re: How to track velocity script link

@SanfordWhiteman @Jon_Wright It is not working.

What I meant by hardcoding is that I placed the code just before the <a> tag and tried executing it. I don't see it working, it renders anchor tag with blank URL.

 

I tried using it in token as well but no luck. 

 

Thanks in advance

 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to track velocity script link


I tried using it in token as well but no luck. 

You should be using it in an Email Script token, obviously. And you must make sure the required Opportunity fields are checked in the tree on the right-hand-side of Script Editor.

 

It’s really not clear what you’ve tried and what you’ve observed at this point.

 

Also note OpportunityList.get(0) is getting what you should treat as a random Opportunity. If you want to get a  specific Opportunity, sort and/or filter the list.

p4vankum4r88
Level 2

Re: How to track velocity script link

I am sorry for missing the details in my post. I have used it in the email script token and I have selected the field in the right hand column and I have called the email script token into my html but it is still not working.  

 

I am attaching the screenshots for your reference, Is there a way I can connect with you live? I really appreciate the help you are doingMicrosoftTeams-image (7).pngMicrosoftTeams-image (6).png

MicrosoftTeams-image (7).png

SanfordWhiteman
Level 10 - Community Moderator

Re: How to track velocity script link


MicrosoftTeams-image (7).png

Your Velocity is outputting an entire <a> (up to and including the closing </a>). As it should, this is the only way to get tracked links.

 

But you can’t put that link inside the href of another <a> tag in the body of your email!

 

You put only the {{my.token}}. Then it’s replaced by the link. (This is an HTML rule more than a Marketo or Velocity thing.)

p4vankum4r88
Level 2

Re: How to track velocity script link

I just added the token into html without anchor tag and I don't see it working.  The variable doesn't seem to compile. Should I make any changes to Marketo settings

 

Here is the screenshot

linkerror.PNG