Using a Marketo Token in a URL

kenmckown
Level 3

Using a Marketo Token in a URL

I am adding a Marketo Token into a link on a Landing Page which is not allowing me to save the page. I reached out to support and they are saying this is not possible. But we tested this and it worked fine before.

 

So my question is can you actually use a Marketo token in a URL on a landing page?

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Using a Marketo Token in a URL

You can certainly use {{lead.tokens}}, {{member.tokens}}, etc. on Landing Pages and inject them into links. I'm not clear exactly what you're asking and how support would've answered to the contrary. Can you give a concrete example please?

kenmckown
Level 3

Re: Using a Marketo Token in a URL

I appreciate the response, the issue was that we had "%20" for the space between characters instead of just a space. This was breaking the code and not allowing to be approved.

SanfordWhiteman
Level 10 - Community Moderator

Re: Using a Marketo Token in a URL

The URL-encoded space %20 is the correct way to include spaces in URLs. While browsers will encode the space for you if you forget, best practice is to encode all non-ASCII and reserved characters in the source, that is, in the href.

 

So purposely not encoding is not a good choice. In fact you can’t just output tokens inside markup like:

<a href="https://www.example.com/{{my.Path Segment}}/page?{{lead.Query Param}}">Go</a>

unless you ensure the values are URL-encoded. If the stored value in Marketo is not URL-encoded you must do so using JavaScript before injecting it into the final href. (That’s why I was careful to say “inject” and not “include” above.)

 

I’m not able to reproduce a problem with having %20 in a pre-encoded {{my.token}} value and outputting it directly into an href. Can you please explain exactly where you were including %20? Was it in the token name, not its value, perhaps?