Hello all - I can't seem to find this answer, so any help is appreciated. I'd like to automatically append the email id (marketo asset email id) to a query string parameter. As it's not available in the field list when creating an Email Script token, does that mean it's impossible? Thanks!
Solved! Go to Solution.
You can use the code here (which should be cross-posted to the official Products blog but I haven’t gotten around to it!).
You can use the code here (which should be cross-posted to the official Products blog but I haven’t gotten around to it!).
Thank you, @SanfordWhiteman! I can't say I know exactly how this works even having ChatGPT explain it to me haha. But with limiting the printed value to ${marketoSend.AssetId}, this works perfectly.
There is quite a lot of special sauce in there for sure.
I've hit a bump in the road and would love to know if what I'm doing is achievable.
I've modified the script to have some text before and after the email id, and set this as a folder token as "{{my.utm source medium content}}". I combine this token with "{{my.utm campaign}}" which is a local text token used in the Program and create a URL as 'https://example.com?{{my.utm source medium content}}{{my.utm campaign}}'. The output would look like this:
https://example.com?utm_medium=email&utm_source=marketo&utm_content=99999&utm_campaign=test_campaign
This works as expected in the email preview, and when the email is sent BUT ONLY when the link is not tracked. When the link is tracked, the email script is written in full in the place of the {{my.utm source medium content}} token,
<a href="example.com?{{my.utm source medium content}}{{my.utm campaign}}" target="_blank">HYPERLINK TEXT</a>
turns into this:
https://www.example.com/?&mkt_tok=MjgwLVFESy0yMTUAAAGS_MzEaudY6U_C7CICOrqn9-0QWoUXLqnVQJwNjMGngtk4Ka...
Disabling the mkt_tok does not remedy the issue, though I would not want to disable this anyway.
I've gone through this lengthy post and am hoping what I am trying to do is still possible!
EDIT: I am now also seeing this, which suggests my plan is not possible. A helper field would not be able to access the specific email being sent like the workaround suggests Email Script Token Not Resolving in a URL Link - Marketing Nation (marketo.com).
Thank you for anyone taking the time to look at this 🙂, especially @SanfordWhiteman!
Token Script for {{my.utm source medium content}}:
#set ($utm_text = "utm_medium=email&utm_source=marketo&utm_content=")
#set ($utm_campaign_text = "&utm_campaign=")
#set( $marketoSend = {} )
#set( $delim = ":|-" )
#set( $values = $mktmail.xMarketoIdHdr.split($delim) )
#set( $numParts = $values.size() )
## Campaign Run ID not relevant in Preview, Test Variant not always present, etc.
#set( $keyTemplatesBySize = {
13 : "MunchkinId-+MunchkinId-+MunchkinId::CampaignId:StepId::AssetId::CampaignRunId:LeadId--TestVariantId",
12 : "MunchkinId-+MunchkinId-+MunchkinId::CampaignId:StepId::AssetId::CampaignRunId:LeadId-",
11 : "MunchkinId-+MunchkinId-+MunchkinId::CampaignId:StepId::AssetId::CampaignRunId:LeadId",
"*" : "MunchkinId-+MunchkinId-+MunchkinId::CampaignId:StepId::AssetId::LeadId"
} )
#set( $marketoIdKeys = $display.alt($keyTemplatesBySize[$numParts],$keyTemplatesBySize["*"]) )
#set( $keys = $marketoIdKeys.split($delim) )
## loop interesting keys
#foreach( $key in $keys )
#if( !$key.isEmpty() )
#if( $key.startsWith("+") )
#set( $finalKey = $key.substring(1) )
#set( $marketoSend[$finalKey] = $marketoSend[$finalKey] + "-" + $values[$foreach.index] )
#else
#set( $finalKey = $key )
#set( $marketoSend[$finalKey] = $values[$foreach.index] )
#end
#end
#end
${utm_text}${marketoSend.AssetId}${utm_campaign_text}