SOLVED

Velocity email scripting - beginner's guide?

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity email scripting - beginner's guide?

Send Sample shouldn't be used to test Velocity... send real emails.

Nicholas_Manojl
Level 9

Re: Velocity email scripting - beginner's guide?

Or the 'Preview Email / View by Lead' function.

(when this is the most helpful thing you can add to a thread because the rest has been covered off so thoroughly)

Anonymous
Not applicable

Re: Velocity email scripting - beginner's guide?

Thanks Nicholas,

Actually I didn't know that this was possible. I used to use this feature in Mailchimp, very helpful.

Have a great day,

Thomas

Anonymous
Not applicable

Re: Velocity email scripting - beginner's guide?

Good day Sanford,

May I disturb you once more to ask if this is the way you would proceed to personalize a subject line? Thanks!

Thomas

#if(!$lead.FirstName.isEmpty())

  #set($subject = "$lead.FirstName, beat grocery stores at their own game with our new hit app")

#else

  #set($subject = "Beat grocery stores at their own game with our new hit app")

#end

${subject}

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity email scripting - beginner's guide?

Sure, LGTM. The only thing I might change is change to ${formal.notation} in the #set. FN tends to be overused in comparisons and when calling methods -- and can actually break stuff there, as we've seen. But it's underused within quotation marks, where it adds clarity and is a net good.

Anonymous
Not applicable

Re: Velocity email scripting - beginner's guide?

Thanks Sanford, I changed the notation between quotation marks accordingly.

Thomas

Anonymous
Not applicable

Re: Velocity email scripting - beginner's guide?

Do you put the java script directly in the source code of the email you are working with?

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity email scripting - beginner's guide?

Not JavaScript: Velocity (VTL)! Very, very different.

As I mentioned on your other thread, VTL goes in a token. Then the token name goes in your email.

Luke_Wotton
Level 4

Re: Velocity email scripting - beginner's guide?

Sanford, awesome work.

Question - can you put tokens inside a script token?

Example.

If foo = bar

token = {{my.token1}}

else

token = {{my.token2}}

Or does Marketo not evaluate tokens inside tokens?

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity email scripting - beginner's guide?

Generic text/HTML tokens, no.

Other Velocity token values, yes (though you don't need to reference them as {{my.tokens}} but as simple Velocity vars).

When you use Velocity a lot, you tend to stop using text tokens and instead work in VTL semi-exclusively.  For example, instead of a text token

  twitter.com/ourprimaryhandle

you have a Velocity token

#set( $globals = {

   "twitterHandle" : "twitter.com/ourprimaryhandle",

   "facebookPage" : "facebook.com/ourpage"

} )

Then include the {{my.globals}} token (in the template, typically) and you have access to to $globals.twitterHandle in any subsequent script.