Velocity Scripting for URLs | Adobe Higher Education
Skip to main content
Level 2
March 22, 2022
Respondido

Velocity Scripting for URLs

  • March 22, 2022
  • 1 resposta
  • 2779 Visualizações
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?
Este tópico foi fechado para respostas.
Melhor resposta por Darshil_Shah1

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!

1 Resposta

Darshil_Shah1
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
March 22, 2022

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!

Level 1
September 12, 2022

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>