Email Script Tokens for Real Beginners | Community
Skip to main content
Allison_Proehl
Level 4
September 11, 2019
Solved

Email Script Tokens for Real Beginners

  • September 11, 2019
  • 2 replies
  • 5877 views

Does anyone have really beginner-level resources for learning how to do email script tokening? I've never done it before and feel like I missing out on some really cool/useful stuff. 

One of the problems I'm trying to solve is:

If the lead picks "Consultant A" then show "Schedule Consultation" (with a hyperlink to Consultant A's calendar.)

then,

If the lead picks "Consultant B" then show "Schedule Consultation" (with a hyperlink to Consultant B's calendar.)

Lastly, 

if the lead picks "Unsure" then show "Schedule Consultation" (with a hyperlink to Consultant A's calendar, b/c they are our default.)

I've read a couple of @Sanford Whiteman‌ blogs, and I feel like they are way over my head.

All help appreciated!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Something I mention in my Velocity classes is that the language was originally created as an easier-to-use, faster-to-market way to write code in a Java shop. Meaning it was still expected to be used by developers -- maybe very junior ones, but not folks who had zero interest in/exposure to datatypes and OO ideas.

It's apparent from the Velocity Tools docs that you're supposed to know what an int[] is (an array of int primitives) and there's no special explanation of stuff like that. Even when introducing the very simple #foreach/#end structures, there's mention of Collections and Iterators, which you could skip over and still write good code but there's a clue to a wider world.

Velocity does a ton of automatic type juggling for you that Java would never do, making it without a doubt exponentially faster for writing emails, web pages, or other text output. But if you ignore the Java underpinnings, you'll be  confused when you run into a fatal error thrown from Java-land (like aStringIndexOutOfBoundsException).

I'm planning some short(ish) posts on the Marketo blog to deal with individual technical details of Velocity. They won't be dumbed-down, though, there's just no way to do that.

2 replies

SanfordWhiteman
Level 10
September 11, 2019

Well, learning Velocity is far from an overnight thing.

The reason VTL can seem obscure is... it's real code! Velocity is a real language running on top of Java. (And don't listen to anyone who says it's easy, that's a sign that they aren't a power user.)

As Velocity is very verbose, you want to use collection-centric code.

  • create a collection (i.e. Map) holding your options
  • your consultant field (I'll call it ChosenConsultant since I don't know what the real name is in your instance) is the lookup key, and the URL is the value

#set( $consultantLinks = {
"Consultant A" : "www.example.com/bookwithA",
"Consultant B" : "www.example.com/bookwithB",
"Unsure" : "www.example.com/bookGeneric"
} )
<a href="https://${consultantLinks[$lead.ChosenConsultant]}">Click to schedule</a>
Michael_Florin-2
Level 10
September 12, 2019

Although I am using Email Scripts for years, I still consider myself a beginner - just because I don't speak Java. I kinda understand what Sandford is telling you with the "collection", so I would copy the script, file it somewhere in my own script library, then test it, love it, use it, and thank him sincerely.

Couple of tips: 

  • Start easy. Even a "simple" script with If, ElseIf and Else can bring you a solution to a problem you would never be able to solve otherwise. For example: Build a salutation string for some languages.
  • Create a static list to be used in email previewing. The persons on the list can be just made up persons, so you can add whatever field values to them that your scripts are using.

  • When testing your scripts, always do your final test in a live email send (not a sample), and if your script outputs links, click them. URLs in scripts are tricky beasts.

And no, there are no beginner-level resources out there. If there were, I would have found them. I googled this stuff A LOT. But you're right: If you don't know about scripts, you're missing out. But moving in tiny steps from simple to complex will get you somewhere eventually. We have like ten Marketo users in our organization who are comfortable editing their own scripts, understand them and come up with ideas to build new ones. And none of them are developers.

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
September 12, 2019

Something I mention in my Velocity classes is that the language was originally created as an easier-to-use, faster-to-market way to write code in a Java shop. Meaning it was still expected to be used by developers -- maybe very junior ones, but not folks who had zero interest in/exposure to datatypes and OO ideas.

It's apparent from the Velocity Tools docs that you're supposed to know what an int[] is (an array of int primitives) and there's no special explanation of stuff like that. Even when introducing the very simple #foreach/#end structures, there's mention of Collections and Iterators, which you could skip over and still write good code but there's a clue to a wider world.

Velocity does a ton of automatic type juggling for you that Java would never do, making it without a doubt exponentially faster for writing emails, web pages, or other text output. But if you ignore the Java underpinnings, you'll be  confused when you run into a fatal error thrown from Java-land (like aStringIndexOutOfBoundsException).

I'm planning some short(ish) posts on the Marketo blog to deal with individual technical details of Velocity. They won't be dumbed-down, though, there's just no way to do that.

Allison_Proehl
Level 4
September 16, 2019

Thank you for putting it more in perspective Sanford.  I'm definitely sure its no easy topic to learn, but a worthwhile one. 

I'll keep an eye out for your blogs and maybe when I become a little more experienced I can come back and decipher them!