SOLVED

Re: Marketo Velocity Script Token: replace a variable / add a query string

Go to solution
jolivieri
Level 1

Marketo Velocity Script Token: replace a variable / add a query string

Hello everyone!
I hope you are well and can help me in my research.

 

I should perform an operation with velocity scripts, however, my programming knowledge is really limited and I am struggling to understand how to do it.

 

Basically, from CRM via integration with Marketo, when I create events in the CRM, I carry around a whole set of information that then populates the event tokens on Marketo.

 

Now, I have to carry around links.

 

I can set these links on my CRM, but I cannot make them dynamic (I need to add a querystring with like ?aid={{lead.account}} at the end of each url, and this informations is setted in Marketo and not Dynamics.


Since the links are themselves already contained in a token, I can't put a token inside a token because I've already tried it and it doesn't work.

I tested:

{{my.token}} with the token text as www.google.com/?aid={{lead.account}}.

So I'm wondering: is it possible to set a VLC token that adds ?aid={{lead.account}} to every link in my dem?


If not, is it possible to make the link in the token be:
{{my.token}} with the token text as www.google.com/?aid=REPLACEME.
And via a velocity script replace that "REPLACEME" with {{lead.account}}?


Unfortunately, my skills so technical are limited and I am struggling.
I thank anyone who can help me!

(of course if there are faster or smarter way let me know! I I don't have to compulsorily use a token script)

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Marketo Velocity Script Token: replace a variable / add a query string

Velocity script can reference script/variables set in other VTL tokens, given that they are also referenced/added in the same email asset itself. However, velocity can't access plain text from the email or other custom tokens for manipulation. Check out this similar post on the nation from earlier. It's always better to house the HTML for the entire hyperlink, <a> through /a>, in the VTL token itself, as otherwise, you'd potentially lose on tracking the click activities.

 

View solution in original post

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

Re: Marketo Velocity Script Token: replace a variable / add a query string

This is very much possible using the velocity script. The idea is to form the entire hyperlink, i.e., <a> through </a>, in the velocity token itself and include it in the email at the place where you want to add the hyperlink (make sure you include the local inline style if any, in the <a> stage itself). Make sure you select the field that you are using from the tree in the right in the email script token editor.. Check out the sample script below - 

 

#if(!$lead.account.isEmpty())
<a href="https://www.google.com?aid=$lead.account">Click Me</a>
#else
<a href="https://www.google.com">Click Me</a>
#end

 

jolivieri
Level 1

Re: Marketo Velocity Script Token: replace a variable / add a query string

Thank you very much for the reply Darshil, you are very kind. Really apprecciated. 

 

However, I must ask you for a change:


In this script the link is internal to the script itself.

 

But what if my link is outside the script, maybe in another token or in another part of email?

 

Is it possible to tell the token to perform the operation of adding the querystring to all links placed outside the script but inside the email? 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Marketo Velocity Script Token: replace a variable / add a query string

Velocity script can reference script/variables set in other VTL tokens, given that they are also referenced/added in the same email asset itself. However, velocity can't access plain text from the email or other custom tokens for manipulation. Check out this similar post on the nation from earlier. It's always better to house the HTML for the entire hyperlink, <a> through /a>, in the VTL token itself, as otherwise, you'd potentially lose on tracking the click activities.

 

jolivieri
Level 1

Re: Marketo Velocity Script Token: replace a variable / add a query string

Thank you again for your help!