SOLVED

Re: Velocity Scripting for URLs

Go to solution
kyle_kopp
Level 2

Velocity Scripting for URLs

I am hoping someone can help me with a velocity script question. In all transparency I am not a coder but working to understand.
  • I have a URL in a custom object.
  • The URL contains the full value including https://
  • I have a super basic velocity token pulling in that value. (The script literally only is this: ${cartsAndQuotes_cList.get(0).cartURL}.)
  • The problem I have is that I do not get clicks counted  when I put that token into my CTA in an email template 
  • I think I need a way for the velocity script to return the URL without the https:// portion (so I can add https:// in front of the token in the CTA)
Can anyone point me to a good reference for simple scripting that would help me to accomplish this?
1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Velocity Scripting for URLs

I think below velocity script should help. The script removes the "https://"  from the CO field's value, protocol is then added in the <a> tag to enable the click links tracking.

 

#set( $fieldWithProtocol = $cartsAndQuotes_cList.get(0).cartURL)
#set( $fieldWithoutProtocol = $fieldWithProtocol.replaceAll("^https://","") )
<a href="https://${fieldWithoutProtocol}">My Cart</a>

 

 

Hope this helps!

View solution in original post

2 REPLIES 2
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Velocity Scripting for URLs

I think below velocity script should help. The script removes the "https://"  from the CO field's value, protocol is then added in the <a> tag to enable the click links tracking.

 

#set( $fieldWithProtocol = $cartsAndQuotes_cList.get(0).cartURL)
#set( $fieldWithoutProtocol = $fieldWithProtocol.replaceAll("^https://","") )
<a href="https://${fieldWithoutProtocol}">My Cart</a>

 

 

Hope this helps!

shubham2720
Level 1

Re: Velocity Scripting for URLs

I Tried the same code but it's not working for me.

Instead of populating opportunity field default value is getting populated.

 

Used Code :

<meta class="mktoString" default="en-us" id="fieldWithoutProtocol" mktomodulescope="false" mktoname="fieldWithoutProtocol" />

 

<tr>
<td align="left">
<div class="mktoText" id="fieldWithProtocol" mktoname="fieldWithProtocol">
#set( $fieldWithProtocol = $OpportunityList.get(0).Repayment_Personalized_URL__c) #set( $fieldWithoutProtocol = $fieldWithProtocol.replaceAll("^https://","") )" /&gt;
<a href="https://${fieldWithoutProtocol}">My Cart</a>
</div></td>
</tr>