Velocity Scripting Issue | Community
Skip to main content
Marc_Comption
Level 2
Oct 17, 2019 8:48 PM UTC
Question

Velocity Scripting Issue

#if( $lead.dSSiteID == "3670" )
#set( $ScriptTokenTEST = "www.bigstarhonda.com/special-offer/" )
<a href = "https://${ScriptTokenTEST}">Big Star Honda</a>
#elseif( $lead.dSSiteID == "2289" )
#set( $ScriptTokenTEST = "www.hamertoyota.com/special-offer/" )
<a href = "https://${ScriptTokenTEST}">Hamer Toyota</a>
#else
#set( $ScriptTokenTest = "www.kengarff.com/special-offer/" )
<a href = "https://${ScriptTokenTEST}">Ken Garff</a>
#end
${ScriptTokenTEST}‍‍‍‍‍‍‍‍‍‍‍

Hi All,

Looking for some suggestions on Velocity scripting with tokenized URLs. Our basic email URLs aren't tracking in Marketo so I'm trying to adjust them to make that happen. here is my token code:

#if( $lead.dSSiteID == "3670" )
    #set( $ScriptTokenTEST = "www.bigstarhonda.com/special-offer/" )
    <a href = "https://${ScriptTokenTEST}">Big Star Honda</a>
#elseif( $lead.dSSiteID == "2289" )
    #set( $ScriptTokenTEST = "www.hamertoyota.com/special-offer/" )
    <a href = "https://${ScriptTokenTEST}">Hamer Toyota</a>
#else
    #set( $ScriptTokenTest = "www.kengarff.com/special-offer/" )
    <a href = "https://${ScriptTokenTEST}">Ken Garff</a>
#end
${ScriptTokenTEST}

I attached the email we built from the template Marketo gave us, my thought is that somehow these two are not set up to work together correctly. As a novice as scripting, I could really use some help!

Thanks!

Marc Compton

10 replies

Josh_Pickles
Level 5
Oct 17, 2019 9:29 PM UTC

Hi Marc,

Can you please edit your original question to use the Syntax Highlighter? This will make it easier to refer to your code.

Also, attaching images isn't accessible for everybody on the community. Can you please place your image inline?

Thanks heaps.

JP

Translate
Marc_Comption
Level 2
Oct 17, 2019 9:34 PM UTC

Done. Let me know if you need more detail or a different format.

Translate
SanfordWhiteman
Level 10
Oct 18, 2019 12:44 AM UTC

I'm not having a problem creating a trackable link with that code. Are you testing with real emails (not samples)?

You should however use .equals() instead of == to avoid surprises in Velocity.

#if( $lead.dSSiteID.equals("3670") )
#set( $ScriptTokenTEST = "www.bigstarhonda.com/special-offer/" )
<a href="https://${ScriptTokenTEST}">Big Star Honda</a>
#elseif( $lead.dSSiteID.equals("2289") )
#set( $ScriptTokenTEST = "www.hamertoyota.com/special-offer/" )
<a href="https://${ScriptTokenTEST}">Hamer Toyota</a>
#else
#set( $ScriptTokenTest = "www.kengarff.com/special-offer/" )
<a href="https://${ScriptTokenTEST}">Ken Garff</a>
#end‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Also, don't expect the same results if you output the ${ScriptTokenTEST} variable in 2 places, the very act of debugging like that can disrupt tracking!

Translate