Velocity Scripting Issue | Community
Skip to main content
Marc_Comption
Level 2
October 17, 2019
Question

Velocity Scripting Issue

  • October 17, 2019
  • 1 reply
  • 7993 views
#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

1 reply

Josh_Pickles
Level 5
October 17, 2019

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

Marc_Comption
Level 2
October 17, 2019

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

SanfordWhiteman
Level 10
October 18, 2019

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!