Using Velocity Script to Set URL (and leave out formatting) | Community
Skip to main content
New Participant
May 20, 2024
Question

Using Velocity Script to Set URL (and leave out formatting)

  • May 20, 2024
  • 1 reply
  • 1128 views

Hello, 

I am trying to set a URL in velocity script based on lead data. I do not want to pass any CTA copy in the velocity, how can I set URLs without putting the URLs in a tags? We will be using these links in multiple places in the email, so simply want to pass the URL only, no other formatting. I have not been able to get this work. 

-------------------------------

EXAMPLE 1: 

#if($lead.Language=="English")#set($ctalink="test.com") #elseif($lead.Language=="Spanish")#set($ctalink="test.com/spanish") #elseif($lead.Language=="Japanese")#set($ctalink="test.com/japanese") #end ##print https://$ctalink

 

-NOTES: Tracking for links are broken in this example, tracking does not show up on lead record or report

-----------------------------

EXAMPLE 2: 

#if($lead.Language=="English")#set($ctalink="test.com") #elseif($lead.Language=="Spanish")#set($ctalink="test.com/spanish") #elseif($lead.Language=="Japanese")#set($ctalink="test.com/japanese") #end ##print $ctalink

-NOTES: Links break once the email is sent.

----------------------------

 

How can I pass just the URL from velocity without breaking tracking?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
May 20, 2024

As before, please edit your post to use the Syntax Highlighter so the code is readable.

 

Broadly, what you’re trying to do is impossible. You need to output full links from Velocity.

megkartAuthor
New Participant
May 21, 2024

Thanks for the reply, so outputting the full link will enable tracking? I tried that and don't see on lead record or report.

 

 

#if($lead.Language=="English")#set($ctalink="https://test.com") #elseif($lead.Language=="Spanish")#set($ctalink="https://test.com/spanish") #elseif($lead.Language=="Japanese")#set($ctalink="https://test.com/japanese") #end ##print $ctalink

 

SanfordWhiteman
New Participant
May 21, 2024

By “link” I mean the entire HTML <a> tag (this is in the “links” collection in HTML).

 

Not only the href.

 

As always, the full <a> through </a> need to be output via Velocity.