Learn how to leverage SparkPost Elite’s powerful templating language to create and use complex templates for effective, high-volume messaging campaigns. This session will provide examples of how to create messages with complex structures such as conditional statements, looping, dynamic rendering, and customized links. There will be examples of how this has already been done with SparkPost Elite today, and an overview of where to find support documentation for customers to attempt as well.
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
Insight User Conference Bootcamp - Advanced Templatization
1. 1
Isaac Kim & Fiona Snoddy
Advanced Templatization
November 3, 2015
2. 2
Fiona Snoddy
• Celebrating 1-year anniversary with SparkPost
• Worked on several SPE implementations, including our very first!
• Lives in Columbia, MD
• Loves working-out, water-skiing and watching rugby & ice-hockey
4. 4
Isaac Kim
• Been with SparkPost for 8 months
• Supports both SPE and Momentum implementations
• Lives in Columbia, MD
• Loves fishing, CrossFit, and recently started up archery
9. 9
Transmission Substitution Data
Conditional IF not Statement
Triple Curly Escape URL Link
Conditional IF Statement
Encoded URL Link
Complex Conditional
Statement
Dynamic Content
Simple Loop
Simple Loop with
Multiple Objects
Nested Loop with Objects
11. 11
Templating Overview
• Substitution data can be specified at the transmission and/or
recipient level
• Defined as a JSON object of key/value pairs
• Substitute using double curly brackets
• Substitution data can be used in both text and HMTL templates
• Metadata can be also be used as substitution data
JSON substitution data can be combined with a template to
personalize the recipient’s text, HTML and subject line
13. 13
Conditional Statements
• Can be used standalone as well as in expressions
• Multiple syntax options
If then else
If not
Elseif
If empty
If not empty
• Can be complex
combine with basic/robust substitutions
Concatenated conditions i.e. if A and B and C = x then
The ability to render different per recipient content
based on a given condition(s)
14. 14
Conditional Statements: Syntax Examples
The conditional statement is the following:
if not Syntax
elseif Syntax
{{if not signed_up}}
Don't forget to sign up!
{{end}}
{{if signed_up}}
Welcome, thanks for signing up!
{{elseif rejected_sign_up}}
We won't bother you anymore!
{{else}}
Don’t forget to sign up!
{{end}}
15. 15
Conditional Statements: Syntax Examples
The conditional statement is the following:
if empty Syntax
If not empty Syntax
{{ if not empty(orders) }}
Here is a list of your orders
{{else}}
You have no outstanding orders
{{ end }}
{{ if empty(orders) }}
You have no outstanding orders
{{ else }}
Here is the list of your orders
{{ end }}
16. 16
Conditional Statements: Real-world Application
{{if Attending_Insight}}
You'll be on California's central coast in November, so prepare for multiple scenarios. November
temperatures in Monterey average 65/50 with mid to low chance of rain. For up to the minute
weather information for the area, check out <a href="#">weather.com</a>!</p>
• <a href="https://www.google.com/?gws_rd=ssl#q=weather+{{local_city}}">Your Local Area
Weather Report </a><br>
• <a href="https://www.google.com/?gws_rd=ssl#q=weather+{{dest_city}}">Your Destination
Area Weather Report</a><br>
{{else}}
It's not too late to register and attend Insight! Sign up today so you can enjoy the lovely weather on
California's central coast. For weather updates, check out <a href="#">weather.com</a>!</p>
{{end}}
Substitution Data:
“Attending_Insight” : true,
Template:
17. 17
Conditional Statements: Real-world Application
{{if not Airports[departAirport]}}
Hi {{ firstName or 'there' }}, You do not appear to be traveling anywhere. This email must be a
mistake.
{{else}}
{{if Airports[departAirport] and Airports[departAirport].city then}}
Hi {{ firstName or 'there' }}, You are planning a trip from {{departAirport}} in
{{Airports[departAirport].city}} to {{arriveAirport}} in {{Airports[arriveAirport].city}}.
{{end}}
{{end}}
Template:
Substitution Data:
"arriveAirport":"SFO",
"Airports":{
"SFO":{
"code":"SFO",
"city":"San Francisco",
"name":"San Francisco International Airport”,
18. 18
Personalized Links
• Substitution data can be used to replace part or all of a URL
• The substitution engine automatically encodes the
substitution values to handle special characters
• Encoding can be disabled on a per substitution basis
(triple curly brackets)
The ability to render a target URL link containing
one or more substitutions
19. 19
Personalized Links (URL Encoding):
Real-world Application
Personalized Link in Template
<a href="https://www.google.com/?gws_rd=ssl#q=weather+{{local_city}}">Your Local Area
Weather Report </a>
{
“local_city” : “ellicott city”,
}
<a href="https://www.google.com/?gws_rd=ssl#q=weather+ellicott%20city">Your Local
Area Weather Report </a>
Link (with URL encoding) in Email
Substitution Data
20. 20
Personalized Links (Disabling URL Encoding):
Real-world Application
Please be sure to refer your fellow coworkers to sign up to the {{year}} INSIGHT Conference by
sending them to this <a href="{{registration_link}}">link </a> or this <a
href="{{{registration_link}}}">link here</a></a>!</p>
"registration_link": "https://www.regonline.com/register/checkin.aspx?
EventId=1693737&MethodId=0& EventSessionId=&startnewreg=1",
https://www.regonline.com/register/checkin.aspx?
EventId=1693737&MethodId=0&EventSessionId=&startnewreg=1
Template:
Substitution Data:
Actual Link:
21. 21
• Use render_dynamic_content macro to display chunks
• Links (including the ability to track them) may appear in
either HTML or text chunks
• Substitution statements may appear in these chunks
• Dynamic content must be specified at the transmission level
• Define substitution as “dynamic_html” and/or “dynamic_text”
Dynamic Content
The ability to embed entire chunks of text or HTML within
substitution data rather than within the template
22. 22
Dynamic Content: Real-world Application
{{if dynamic_html.Options}}
{{render_dynamic_content(dynamic_html.Options[REGISTRATION_OPTION])}}
{{end}}
"REGISTRATION_OPTION": "2",
"dynamic_html": {
"Options":{
"1": "<a href="https://www.regonline.com/register/checkin.aspx?
EventId=1693737&MethodId=0&EventSessionId=&startnewreg=1" target="_blank" style="font:
14px arial,helvetica,sans-serif; color:#003a6f; text-decoration:underline;" title="Register Now
">Register Here Today</a>",
"2": "<a href="https://www.messagesystems.com/insight/agenda" target="_blank" style=
"font:14px arial,helvetica,sans-serif; color:#003a6f; text-decoration:underline;" title="Insight
Conference Agenda">Check Out the Agenda Here</a>",
"3": "<a href="https://www.messagesystems.com/insight/about" target="_blank" style=
"font:14px arial,helvetica,sans-serif; color:#003a6f; text-decoration:underline;" title="About Insight
2015">Learn More About Insight Here</a>” }
Substitution Data
Template Statement:
23. 23
Looping
The ability to iterate over a sequential array
of objects or values (strings)
• Implement using the “each” keyword and “loop_var” variable
• Can iterate over more complex data structures, going multiple
levels down (nested looping) using “loop_vars” variable
• Can use HTML within the loop to generate template content
(tables, text, bullets, lists, etc.)