Hi Team,
I’m trying to understand two things:
The Use of My Tokens versus Lead Tokens in Marketo.
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
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.
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.
Do let me in case if you need anything else
Regards,
Akshat