Re: Use of My Tokens vs. Lead Tokens in Marketo

ashah123
Level 3

Hi Team,

 

I’m trying to understand two things:

 

  1. The Use of My Tokens versus Lead Tokens in Marketo.

  2. How to use a Velocity script to handle a field in Marketo that contains a full URL.

 

1. The Use of My Tokens versus Lead Tokens in Marketo.

 

We have a string field in Marketo called Referral Code, and we need to append this value dynamically within a URL in our emails.

Initially, I tried using a My Token (with an email script inside it) and then referenced that token in the URL. While the value appeared correctly in Preview, the actual test send did not resolve the referral code — instead, the literal token ({{my.TokenName}}) appeared in the final URL.

 

I found that adding class="mktNoTrack" allows the My Token to render correctly inside the link, but it also makes the URL untracked, which we want to avoid.

 

Recently, I tested using the lead-level token directly in the URL (e.g., {{lead.Referral Code}}). This worked correctly — the URL resolved as expected and the click was fully tracked in Marketo reports.

I’m seeing the same behavior with Custom Object fields:

  • When used inside a My Token → link breaks unless we disable tracking

  • When used directly in the URL → link works and stays trackable

So I wanted to understand why placing a field inside a My Token and then using that token in a URL behaves differently compared to using a lead token directly.

 

2. How to use a Velocity script to handle a field in Marketo that contains a full URL.

 

We have a field in Marketo that stores a full URL, but when used as a token it isn’t tracked. Our long-term plan is to sync the field from CRM without the http/https, then prepend it in the email so tracking works.

 

In the meantime, I tested a Marketo-only solution using Velocity to strip the https from the URL. I found this document which was helpful but there is some issue i faced while testing https://nation.marketo.com/t5/product-discussions/trim-http-or-https-from-field-value-via-velocity-o...

 

#set( $fieldWithScheme = $lead.marketingOwnerMSBooking )
#if( $fieldWithScheme && $fieldWithScheme.trim() != "" )
#set( $fieldWithoutScheme = $fieldWithScheme.replaceAll("^https://","") )
${fieldWithoutScheme}#
else
outlook.office365.com/book/BFCFinConsultant-Bookings@LBED.onmicrosoft.com/s/EGn2yKIMfUO09ZSFJQ-jSw2#
end

 

ashah123_0-1764682128110.png

 

 

In the preview, the Velocity output worked correctly, but when I sent a live test email the link didn’t resolve. In the activity log, Marketo logged the literal Velocity token output instead of the fully rendered link. So even though it appeared to work in preview, the live send didn’t process the Velocity token the same way, which caused the link to break.

ashah123_2-1764682188656.png

 

Not sure what went wrong here, but the link didn’t work in the live test and wasn’t tracked. Need guidance on how to make the whole URL within a token to work using velocity script and also to make it trackable.

ashah123_3-1764682809578.png

 

Do let me in case if you need anything else

 

Regards,

Akshat

 

 

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Also note the Velocity code you posted has fatal syntax errors. There’s no way it ran like that (missing leading # in 2 places).