Product
Get personal with your contacts using Mailjet’s templating language
Mailjet introduces its own templating language, to make personalizing your transactional emails even easier.
PUBLISHED ON
Today is an exciting day at Mailjet, as we’re releasing a new major feature for developers: our very own templating language. While Passport for Transactional gives you the opportunity to use templates designed with Passport for your transactional emails, pushing the collaboration between your marketing and developer teams to the next level, our templating language allows you to go one step further in personalizing your transactional emails.
You’re probably already familiar with the personalized tags that enable you to address your users by name, using something such as “Hello {{first_name}}”. Well now, you can do way better than that, by adapting the content - including the subject line - and the layout of your email, according to your users’ data. Any data, really, as long as it matters to you: it can be their history with your brand, their favorite soccer team or just their gender. It’s all up to you!
To give you a better idea of what you can do with it, let’s have a look at a couple of examples. We’d like to heartily thank our community of beta-testers who helped us identify popular use cases and allowed us to build our templating language accordingly.
Table of content
Using conditions to send super personalized content to the right users
What’s the point of addressing your users by name if you just send them generic content? Our templating language comes with predefined variables (such as your contacts’ first names, email-addresses...), but you can also create your own variables and include them in your template, or even use them in statements. This enables you to include conditional sections, which means you can print different content in your template depending on the status of those conditions.
Instead of having to take care of the logic in-house, all the complexity is handled by Mailjet’s templating language.
Looping over purchased products to send a receipt
A common transactional email we’ve all come across is the receipt. However, it is rather time-consuming to implement and maintain, as you need to get the resources (such as the orders numbers) that are hosted on your servers and alter your template accordingly before sending it. Nonetheless, the raw structure of a receipt is quite simple. You’ll usually find information that is repeated, such as the orders numbers, dates and prices.
Now, with our templating language, you don’t have to handle the alteration of the template on your own, as it is natively supported by our API. All you have to do is call our API with your template ID (yes, the template can be designed in Passport for Transactional and be hosted on Mailjet’s servers!) and, as long as you used the language on your template, the API will alter it for you. It’s as simple as that! Check out this email receipt:
Here is what the code would look like for this example of transactional email:
We’re convinced you’ll find a lot of other use cases where the for loop speeds up your productivity and makes things easier, such as looping over a list of articles for a tailored daily digest or a list of missed messages in a chat app to send a recap.
What’s next
Discover the full list of statements, expressions, operators and functions available in the templating language in our documentation. Sky’s the limit when it comes to combining them! We can’t wait to hear about all the new ways of engaging with your users you come up with, so please share your use cases and implementations with us!
On our side, we’ll make sure we add new features into our templating language so you can do even more with less code.
Speaking of doing more with less, have you checked out MJML, our open-source markup language that makes responsive email development easy? We had an awesome welcome from the community (800+ upvotes on Product Hunt, 2,000+ stars on GitHub) and want to thank everyone who supported us!
With Passport, Passport for transactional, MJML and our brand new templating language, you now have all you need to make your emails rock!