Velocity Script with Custom Object and

Level 2

Velocity Script with Custom Object and

Having troubles with velocity scripting on Custom Objects. Looking to do a table that provides dynamic content for the text as well as links that are able to be referenced for that text.


Here is the script that has been built so far setting the parameters for our utm string as well:

## Set UTM Parameter Values

#set( $progName = "name of program here" )
#set( $emailID = "xxxxx" )
#set( $leadID = $ )
#set( $utmOffer = "offer" )
#set($url = $myCustomObject.customUrl1)
<a href="https://${url}&utm_source=marketo&utm_medium=email&utm_campaign=${progName}&utm_offer=${utmOffer}&utm_content=assetID:${emailID}&utm_term=mkid:${leadid}


Links hosted on Marketo (Design Studio) are working as they should. Other links non-Marketo hosted are not rendering and breaking somewhere with the mktg-alert tracking wrapper.


Additionally, since is not a field I am able to choose from the Custom Object Tree bc it's not a system token (and we need to use that as it's unique due to dupes in the system) - I tried the marketosend.leadid script and still can't get that piece to work.


Can anyone help troubleshoot?

Level 10 - Community Moderator

Re: Velocity Script with Custom Object and

You can't simply append "&" to any URL and create a valid query string.


You'd have to know that the URL already had a query string, even an empty one. That is, and both already have a query string. Just plain can't have "&" appended, it'll be a broken URL.


In addition, string variables like $progName need to be URL-encoded before being added to URLs. You want ${esc.url($progName)}, not ${progName}. Otherwise, using a reserved character in the string value (which Marketo will never stop you from doing, it's free text) will result in the wrong URL.