Velocity Scripting Issue

Marc_Comption
Level 2

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 10
Josh_Pickles
Level 7

Re: Velocity Scripting Issue

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

Re: Velocity Scripting Issue

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting Issue

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!

Marc_Comption
Level 2

Re: Velocity Scripting Issue

Hi Sanford, 

I made the suggested changes in the token and tested in a live email and got the same results. Any other ideas? I'm also not totally sure what you mean by "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!". Any possibility you can clarify? 

Thanks.

Mark_Price
Level 7

Re: Velocity Scripting Issue

I would suggest:

- double checking the spelling on the token being used  (what you put in for the value of CTA-1 URL)

- remove the $ where you are setting the token and see what happens  (what you put in for the value of CTA-1 URL)

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting Issue

I meant that merely by outputting the same variable multiple times, you can end up testing something else because of Marketo’s sensitivity to the reuse of the same variable.

If what I provided above isn’t working for you perhaps your instance has an old/wrong version of the uberspector (the component that finds links and rewrites them). If you have a moment to get on my JoinMe, I’d like to look into that, as I need to keep track of such discrepancies.

Marc_Comption
Level 2

Re: Velocity Scripting Issue

Hi Sanford, 

I'm fine to review over JoinMe if you have time today at some point. Let me know what time frames work for you. My schedule's wide open today. 

Thanks.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting Issue

How about 4:15pm Eastern?

Marc_Comption
Level 2

Re: Velocity Scripting Issue

That works. If you want to send a meeting URL you can send it to marcc@kengarff.com

Look forward to it!