Hello community,
Facing an issue with velocity script, the url variable is not populating correctly & the output is "https://${url}".
If https:// is included in the baseUrl variable, it works, and the URL is populated correctly, but the click link tracking is lost in the activity log.
What could be the issue here & how can it be fixed without losing the click-link tracking?
#set($utm_source="Nurture")
#set($utm_content="WXDWW")
#set($utm_term="20AQR")
#set($utm_id = "utm_id=NewsletterENThink")
#set($baseUrl = "www.abc.com/account/reg/us-en/signup?utm_source=$utm_source&utm_content=$utm_content&utm_term=$utm_term")
#set($url =$baseUrl+"&" + $utm_id)
<a style="border-collapse: collapse; mso-line-height-rule: exactly; text-decoration: none; color: hashtag#0f62fe;" href="https://${url}" target="_blank" rel="noopener"> Subscribe now </a>
You shouldn’t be building URLs manually in this day and age — you’ll inevitably mess up encoding.
Simply use LinkTool ($link
) to build the URL, then output the constant https://
followed by the relevant URL parts:
#set( $signupUrl = $link.uri("https://www.example.com/account/reg/us-en/signup") )
#set( $void = $signupUrl.setParam("utm_source", "Nurture", false) )
#set( $void = $signupUrl.setParam("utm_content", "WXDWW", false) )
#set( $void = $signupUrl.setParam("utm_term", "20AQR", false) )
#set( $void = $signupUrl.setParam("utm_id", "NewsletterENThink", false) )
<a style="border-collapse: collapse; mso-line-height-rule: exactly; text-decoration: none; color: #0f62fe;"
href="https://${signupUrl.getHost()}${signupUrl.getPath()}?${signupUrl.getQuery()}" target="_blank" rel="noopener"> Subscribe now </a>