How to Pipe Mailjet Data to a Data Warehouse — and Why You Should

As the central hub for your team’s messages, customers, and apps, Mailjet offers all the benefits of group email management and collaboration. But beyond the obvious functionality, the Mailjet platform is chock-full of data — and you can use that data to surface valuable insights for your team.

In many organizations, corporate data lives in silo’s that don’t talk to each other. In addition to Mailjet, perhaps you use a payment platform like Stripe or Square, advertising networks like Google Ads or Facebook Ads, an analytics platform like Google Analytics, customer service software like Intercom or Zendesk, and in-house databases. You track information for the same customers in all these platforms, but how can you get a full picture of every way your customers are interacting with your business?

The best way to correlate that information is to create a data warehouse that consolidates all of your data into a single location. Most businesses nowadays use cloud data warehouses to do this.

Three tiers of the data analytics architecture

Data sources like Mailjet form a foundation for a data analytics stack that comprises three additional tiers: ETL (extract, transform, load) software, data warehouse, and business intelligence (BI) software.

Stitch provides a simple, powerful ETL service for businesses of all sizes. Signup is simple — you can be moving data from one or more sources to a data warehouse in five minutes.

The last few years have seen the emergence of cloud-native data warehouses like Amazon Redshift, Google BigQuery, Snowflake, and Microsoft Azure SQL Data Warehouse. Because they run on cloud infrastructure that scales quickly and cost-effectively to meet performance demands, they can handle transformation using the same hardware on which the data warehouse runs.

Finally, to unlock the value of your data, you can connect a BI or data visualization tool to your data warehouse and create reports that analyze data from multiple sources, which you can share via browser-based dashboards.

Setting up a data warehouse

Let’s set up a three-tiered data analytics stack, starting with the data warehouse. If your organization generates business analytics reports, chances are you already have an account with one of these data warehouses, but if you don’t, choose one that meets your needs. If you choose Redshift, BigQuery, Snowflake, Azure SQL Data Warehouse, or one of the other destinations Stitch supports, you can also follow the setup steps for your data warehouse in the Stitch documentation.

Setting up Stitch for ETL

The next step is setting up an ETL pipeline to move data from Mailjet and other data sources to the data warehouse. Stitch makes extracting data from a source and loading it into a data warehouse easy. To get started, visit Stitch’s signup page, enter your email address, then enter your name and a password.

Add an integration

Next, add Mailjet as an integration within Stitch. Click on the Mailjet icon to get started:

 

 

The next screen prompts for a name for the integration. This name will display on the Stitch Dashboard for the integration, and it’ll also be used to create the schema in your destination. Choose something descriptive but not too long.

 

 

When you click Save, Stitch will generate a webhook token URL:

 

Follow the instructions on the screen to paste the URL into Mailjet as an endpoint for the events you want to track. Once you save it, all future events of the types you’ve selected will be replicated to your data warehouse — but first you have to connect your data warehouse to Stitch as a destination.

Click Continue, then All Done, to get back to the Stitch dashboard. Scroll up to the top of the screen and click on Destination.

Add a destination

Suppose you’ve chosen an Amazon Redshift data warehouse. Click on the Redshift icon, enter your credentials, then click Check and Save.

 

 

Now all the pieces are in place, and your data is ready to flow.

 

 

When you visit your Stitch dashboard, you’ll see that your integration is marked Active, Continuously Replicated.

From the dashboard you can also add integrations from other data sources. The Stitch documentation walks through the process for each one.

Connecting BI software to your data warehouse

The final stage of the process is connecting an analytics platform to your data warehouse. If you don’t already use BI software, you have dozens to choose from, including such popular options as Tableau, Microsoft Power BI, Google Data Studio, and Looker.

Now you have all the tools you need to see, for example, which customers need the most support or which are the most profitable, and you can tell whether you’ve been communicating with them at an optimal cadence or targeting ads at the best cohort.

That’s all there is to it. Using an ETL tool like Stitch to move data from Mailjet and other sources into a data warehouse lets you leverage the power of BI tools to correlate and report on all of your valuable data.

What Is a Webhook and Why Do You Need It

Wondering what is a webhook and how it works?

Well, just think about the amount of information you get about the emails you send. We’re sure you love all the detailed stats Mailjet offers, but you wish there was just a way the right ones would come to you, so you wouldn’t need to you looking out for them. Well, luckily, there actually is. Today, we’ll tell you all about webhooks, how to set them up and how to use them to drive your email program.

What is a webhook?

Imagine that you have an online store and you want to offer a special discount for anyone opening your email in the first 24 hours. You can do it manually, by checking your email stats regularly and manually sending those who opened the discount code. But that would take you a lot of time, right?

Or you can do it automatically with webhooks, which will trigger a message with the additional discount to anyone that opens your email. Sounds more efficient, right?

Simply said, webhooks are events that trigger an action. In most cases, they are used for communication between systems. This is the simplest way of getting an alert when something happens in another system. They are called webhooks because they work as software hooks over the web.

How do webhooks work?

Let’s take your bank as an example. When you make a withdrawal using an ATM, the machine checks your balance and gives you the amount you requested. Once this operation is done, your balance is updated and this change triggers an action – an SMS is sent with the details of the withdrawal.

That’s how webhooks work. An action serves as a trigger for another action. The rest is a popular architecture used to communicate between systems.

A webhook is a HTTP callback: a HTTP POST that occurs when something happen – an event-notification via HTTP POST. Webhooks are used for real time notifications, so your system can be updated right when the event takes place.

Most commonly, webhooks are HTTP callback points that are defined by the user. They allow you to register an http:// or https:// URL where the event data can be stored in JSON or XMLformats. After that, you will be able to do what you want with the data you retrieve and store from a certain event.

The core mechanics of webhooks consist on making an HTTP request to a user’s specified URL. A webhook makes an HTTP callback to a URL that has to be configured by the system which receives the data.

That URL is called webhook endpoint. Webhook endpoints need to be public and it’s important that this URL belongs to the receiving system. The callback is triggered whenever there is an event you’d like to notify another system about.

For Mailjet, this webhook is a URL you can add in our system, so you can receive email events, such as “sent” “open, “clicked”, “bounce”, “block”, “spam” or “unsubscribe”. This way, you can either track your messages the whole path, of your message or just “listen” for the status you want.

Let’s go back to the ATM example. When you make the withdrawal, your bank is notified and updates your balance, which is the indication for the system to send you an SMS with all the details.

Webhooks work on the same concept. The ATM is a third-party app/site (webhook provider) that sends a signal when a specified event occurs. The system that sends you the SMS is what is known as the “listener”. The listener is the URL that receives the webhooks calls and performs a predefined action after that – in this case, sending the SMS. Webhooks are a programming mechanism designed to receive data that originates in some external system, in real time. In this case, that system is the bank account. Is it clearer now?

But what sort of things can you do with webhooks? Among other things, you can:

  • Synchronize systems in real time;
  • Send any kind of notification;
  • Process the data however you want;
  • Create reports;
  • And almost anything else you can think about!

 

Why do we need webhooks?

There are two ways your apps can communicate with each other to share information: polling and webhooks. In our example with the bank, polling would be going to your bank and asking what your balance is each time you make a withdrawal.

Nowadays, everyone needs a simpler way to get data out in real time, so they can easily do whatever they want with it. That means, no polling every minute for large exports that your system would then need to parse, risking a system overload or losing the data if there’s a bug. Using HTTP is a simpler and easier solution, as webhooks are automated messages sent from apps when something happens.

polling_vs_webhookSource: Cloud Elements – check out their post to learn more about the difference between polling and using webhooks.

There are two ways you can use webhooks:

  1. To receive the event information and store it;
  2. To receive the event information and pass it on;

Let’s look into these two scenarios closer.

To receive the event information and store it:

The so called “push” is the simplest way to use webhooks. As we already mentioned, there is no need to be polling your data every few minutes to find out if there is new information. You can just get the new information directly by using webhooks. You will be able to store it till you need it for something else. Basically, the system you configured with your webhook will PUSH the information you need when it arrives.

To receive the event information and pass it on:

The so called “pipe” happens when your webhook not only receives the information for which it listens, but goes on to do something new with it, like triggering actions. You could create a script, register its URL on your site, and send an email when a visitor creates an account. Or create a script that updates the quantity of products available every time a new purchase is made.

With webhooks, you can actually do whatever you want or need! And it is simple and efficient, because you are not wasting your time requesting for enormous amount of data – you are receiving the new data when it arrives!

How can you use webhooks with Mailjet?

With webhooks, you can easily receive each open or click event right after it happens, or track bounces and blocks as they happen. Imagine that in 15 minutes more than 60% of your emails to a destination are blocked? Thanks to the events you are receiving in real time, you’ll be able to detect this immediately and take action.

You can always use the events to create your personalized dashboard in whatever internal application you use, to process the data you want as you wish. You’ll only have the events you need and track the most relevant data. Or you can use the events received on your webhook as triggers for a new email to be send, to create a personalized automated flow for all of your users.

Mailjet event examples

Let’s dig a bit deeper into what the events you receive on those webhooks look like.This is what you’ll get when you receive an open event:

{
“event”: “open”,
“time”: 1433103519,
“MessageID”: 19421777396190490,
“email”: “api@mailjet.com”,
“mj_campaign_id”: 7173,
“mj_contact_id”: 320,
“customcampaign”: “”,
“CustomID”: “helloworld”,
“Payload”: “”,
“ip”: “127.0.0.1”,
“geo”: “US”,
“agent”: “Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0”
}

You can see what message was opened, when exactly and other useful information that you can use however you wish.

Now, let’s check out a bounce event:

{
“event”: “bounce”,
“time”: 1430812195,
“MessageID”: 13792286917004336,
“email”: “bounce@mailjet.com”,
“mj_campaign_id”: 0,
“mj_contact_id”: 0,
“customcampaign”: “”,
“CustomID”: “helloworld”,
“Payload”: “”,
“blocked”: true,
“hard_bounce”: true,
“error_related_to”: “recipient”,
“error”: “user unknown”
}

Here you can also see what the error was, in the field “error”. In this case, the error indicates it’s an “unknown user”, which lets you know that it is better not to try and reach out to this user again. This could be used to synchronize two systems to clean your lists from inactives or incorrect contacts.

In shortly, you can do anything with the events you receive from Mailjet. Use them in your configuration and create what you need!
How can you configure a webhook with Mailjet?

First off, you’ll need the URL from the system from which you want to receive the events. Once you’ve got that, everything else is really simple. That URL will accept data and can activate a workflow to turn the data into something useful. There are two ways to configure your webhooks in Mailjet.

  • Using our API;
  • Using our interface;

 

Using our API

You will need to make one simple call to setup the URL you want to use. Here’s the call:

curl -s \
-X POST \
–user “$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE” \
https://api.mailjet.com/v3/REST/eventcallbackurl \
-H ‘Content-Type: application/json’ \
-d ‘{
“EventType”:”open”,
“Url”:”https://mydomain.com/event_handler”,
“Version”:2
}’

This URL will listen for open events. Each time anyone opens your email you will receive an open event like the one we saw above. Then you can either just store the data or trigger an action, such as sending a new email.

See, it is simple! One call and everything is done. Check out our documentation to get started.

Using our interface

We offer the option to configure the webhook from our interface as well. You can do it from the “My account” page, on the section “Rest API”. You’ll need to choose the option “Event tracking (triggers)”

Event-tracking-mailjet

You’ll be able to add one webhook for all events, or set up specific ones for each type of events.

events-interface-setup-mailjet

You will be able also to test the URL you specified to ensure it’s working properly. If all goes well, it will return a 200 OK HTTP. Any other HTTP code will result in our server retrying the request later.

Our system will retry following these rules:

  • 10 attempts, with 30 seconds between each attempt;
  • After that:10 attempts, with 30 minutes between each attempt;
  • If none of these attempts work, the URL will be suspended;

 

Keep an eye on your webhook for any responses other than a 200 OK. 😉

And this is it! You have a functional webhook that can receive your email events. Use this in your configuration to have your own statistics or custom workflows.

Summing Up

Now you know what a webhook is and why this is the easiest way to track any type of events over the web. Just set up your “listener” and decide what to do with the events it catches.

Using Mailjet’s events will help you track everything that happens with your emails. This is the perfect way to clean your lists or to create your own dashboard in your company’s internal application.

If you want to be the first to know about the latest tech trends or how to use Mailjet, follow us on Twitter and Facebook.

Advanced Email Personalization Using Mailjet’s API

In our previous post in this series we explained what personalization is and provided some useful tips on how and when to best add personalization to your campaigns. We also showed you how to apply standard personalization either manually or using our awesome email builder – Passport. If you missed it be sure to check out our previous article here.

In this article, we are going to dive even deeper into the world of the personalization. Do you want to know how to get to the next level? ? Keep reading and you will see the magic of the advanced personalization, which will allow you to create the perfect email for everyone.

What is advanced email personalization?

Advanced personalization is the easiest way to customize your emails with data that it is collected by your CRM or any other tool you are using to collect your customer’s information. At the moment, this type of personalization e can only be used for transactional emails at Mailjet and by using our template language.

While advanced personalization allows you to do everything we covered in standard personalization, it goes well beyond that.. Not only can you customize [first name] and other basic variables, with advanced personalization,you can customize the content of your email as well, allowing you to send fully personalized emails.. We’ll show you a little later on how exactly you can do this but first to do any kind of personalization you will need personal data for your clients to use.

What data can you use to personalize your email?

The most basic method of collecting information is through a subscription widget You can ask your customers and prospect any number of qualifying questions as they are subscribing to your emails, or opening an account. Starting with their name and email of course, all the way to questions that are going to help you provide a truly personal experience in your campaigns.

For example, if you are selling tickets for events, you could ask “What type of music do you like?” or “What type of movies do you like to watch?” or maybe “Do you prefer live music or live theater?”. get a better idea what to propose to each customer.

But are there other ways to collect data from your customers without asking them additional questions all the time? Yes, you can collect the data for advanced personalization using behavioral website tracking or integrations.

Behavior website tracking

Using behavior website tracking you would have the ability to collect more data than you would ever need about your website visitors using conversion rate optimization (CRO) tools.

User behavior are the activities that your visitors are doing after they land on your site. It could be clicks, scrolling through pages, reading blog posts, taking quizzes, and anything else you think will be useful to you. This could be really helpful at any time of the year,or example if you are tracking that Mike is browsing for items for his wife Laura and his 5 year old boy Jake, you can send him an email with suggestions for the perfect presents for his family.

Integrations

Another good option would be to use integrations. Get subscriber data such as past orders, total money spent, location, purchase data,and more, by integrating your email marketing tool with your CRM or e-commerce platform. There are a lot of integrations that could do all the work for you and you will just have to create the basic template, all the rest will be done automatically. So, at the end your recipient will get a perfect personalized email. For example if you are using our integration with Mautic, you could create a preference center using their how-to article.

Okay, now we have all the data that we need for our emails. Let’s see how to use it with our advanced personalization option.

How to use Advanced Personalization?

When it comes to personalized content, how you can decide which part of the content to be shown to specific targets? When the emails speak to what the subscriber wants to read about, your customers are much more likely to engage with them. Hence, you need to be sure that you offer email content that are targeted and relevant to the recipient. Now that you have all the data and segments set, create emails that are most suited and targeted for each individual subscriber.

Dynamic content is something that you can easily do with the our advanced personalization or the so called template language via our API. You can easily mix up the simple and the advanced personalization in one template, so you would have one beautiful email at the end.

What is the difference between both types? As we saw, standard personalization is taking the information from the data you provided while uploading your list at Mailjet, so we already have this information on our side.

But advanced personalization is actually asking your systems about the information that we should display in the email. In the API call you are going to set up the properties and configure the path to the destination from where the API call should take them.

There is a slight difference also in the way the both type of personalizations are being set up. If you are creating your template in Passport to use the standard personalization, you can use the way described in our previous article, or manually by typing:

{{data:nameoftheproperty:”defaultvalue”}}

The advanced personalization could be set up by manually typing the following syntax:

{{var:nameoftheproperty:”defaultvalue”}}

As you can see the only difference is in the type of variable – one is data and the other is var. You can add it in this way in Passport or in any MJML/HTML template you are creating.

The way you should define those properties in your API calls, depends on the API version you are using.

  • In Send API v3.1 you should do it with the following piece of code:
"Variables": {
              "day": "Monday"
}
  • In Send API v3 the code is:
"Vars":{"day":"Monday"}

In the API call you can set up the path to the destination from which the variable should be taken. Our system will call this destination and replace the property with the value your system sends us.

Using Dynamic Content to Personalize Emails

One of the useful features of the template language is the dynamic content. Using conditions and loops, you can show part of your content only to the recipients you want.

You won’t recommend Mike buy his wife Laura men’s shoes right? Or his son a kitchen dining set?

We know that you can create such dynamic content using HTML without any issue, but now this is possible with Passport as well. Simply drag and drop the template language section wherever you want within the template, like shown below:

Templating-Language-section

You can create any condition, or loop where the content can be shown to each of your segments. You can also use any information that you have saved in your CRM or database. For example age, gender, city, or interests. If you are using behavioral website tracking, this could also be used as source of information.

Another option would be to segment a whole section using Passport. To do this, you will need to select the section you want, and in the upper left corner you will have the option to add a property and segment based on it.

template-language-block

Click on “Add condition” and configure the right option for your specific use case. You can choose whether the property should be equal to a specific term, or greater than a value, or less than any value you choose.

template-language-condition

You can find everything you need on how to use the dynamic content with our template language in this article.

Personalizing the content and copy of the email boosts engagement and loyalty. Sending tailor-made and relevant content increases the click-through rates of your emails. By dynamically changing content, you will be able to send the most relevant emails to every subscriber. They will see offers and products that they are more likely to be interested in, thereby increasing the likelihood of a purchase.

What can you add as dynamic content? Almost anything! Here are some ideas to get you started:

  • VIP Loyalty section – categorize your subscribers based on their purchases and send specially tailored offers and discounts to them. This will help your brand engage customers stronger and drive revenue.
  • Recommendations – when you send recommendations based on a recent purchase, there is an increased chance of them purchasing the recommended products.
  • Wish Lists – you have an item that a customer added in their wish list? Add this as a reminder in the next email you are sending them. They might still want it.
  • Abandoned Carts – someone left behind an item in their cart? Remind them about how awesome that product is, hey they may still want it. You can see how to code abandoned cart emails using MJML in our tutorial.
  • Birthday/Anniversary discounts – what better way to celebrate a birthday than by providing them a discount? You can do the same when someone has been with you for a month, a year, or any anniversary worth celebrating.

Summing Up

The best part is that all of this can easily be done with our email builder Passport! And you will only need to define the variables you used for the advanced personalization in your API call.

You can create one template that full of variables, but everyone of your subscribers will receive an email that is perfectly customized for them. Don’t waste your time with different templates for all your customers You can easily have one template that will adapt to the customer.
With the strategies listed above, you can set up a winning personalized email strategy for your business. Your customers receive dozens of emails everyday, so your email needs to stand out. Personalization can do this for you! Try it out and see how your emails can build stronger relationships between your brand and your customers.

If you want to be the first to know everything new about how to create great emails or use Mailjet in the best way, just follow us on Twitter and Facebook!

How to Set up Template Error Management and Why We Need It

Testing your email templates is tough. Who wants to be checking thousands of code lines for 50 different templates?

That’s why choosing a bug reporting process is necessary. At Mailjet, we are trying to make it as easy as possible for you to do this with our Template Error Management options. Read on and we’ll tell you what Error Reporting is and why you’ll love it. 😉

What is Error Reporting

Good error reporting is essential when building and debugging email templates. No one wants to look at a template for hours, just to see that one small comma is missing…😒 You know the feeling when you want to break your screen with your keyboard? We do and we know how unpleasant it is.

Collaboration Toolkit

As you can imagine, filling out manually a big bug report can take a while. If you need to report dozens of bugs during a testing session, it could take you several hours for one template… This would be painful.

There are many different elements you can include in your bug report. However, using a bug tracker is probably the best way for your organization to move bugs from reported to fixed and help you stay focused. As powerful as bug tracking tools are, the big problem is that you need every person working on the templates to use them and to know how to manage them. But how do you explain to a marketer what “node” means? 🤷

Mailjet’s error reporting is super easy to use for developers, because it gives you a headstart and shows you what to fix and where. For non-developers, it helps to provide more details to you instead of having to rely on insufficient information like say “I got blank / white page”. We all know how no one touched anything, but still something is not working…

template-error-management-fun

Template Error Management at Mailjet

Our goal at Mailjet is to make our products as easy to use as possible. You already know that using our template language is a piece of cake, but it is possible that you missed one curly bracket or a variable was not written correctly and this is breaking everything.

Or you sent the template to the design team to put all the appropriate colors for your brand and someone removed something that seemed strange to them. In fact, it was the most important part of the amazing loop you created.

We don’t want you to waste your time digging into what went wrong, and so we built a solution for you – Template Error Management! We are offering two options:

  • Template Error Reporting
  • Template Error Deliver

Template Error Reporting

Have you ever sent an email but it was not delivered? This could be because our system detected an error with your template and aborted the sending. The main purpose of our template error reporting option is to send you an email to let you know that there is something wrong and provide a detailed explanation of the issue. Here is how it works:

  1. You create a beautiful email template
  2. You compose your API call and declare all of your variables in it
  3. The email is sent by you to our system
  4. Our system checks the template and replaces all the variables with their corresponding values
  5. Our system finds an error
  6. The sending is stopped unless you chose otherwise
  7. Mailjet sends you an email with the error details

So, the first two steps are something that you usually do just perfectly, but this time there was one small mistake in your template. If you have one big template full with loops and conditions, checking everything manually could take forever. This is why we are offering our template error reporting.

To activate it you only need to add this piece of code in your API call:

"TemplateErrorReporting": {
"Email": "youremail@yourdomain.com",
"Name": "Your name"
}

It is important to write the correct email address, because our system will send the report to this address.

These reports should not be an issue for you because the errors are pretty self-explanatory, but we’ve provided some examples of the most common errors below:

unexpected end of template:unfinished end of node ## near ## {{var:url – One of the variables are not closed correctly. In our example above, the variable is missing two closed brackets (i.e. }}) at the end and because of this our template language engine is not recognizing it and cannot compile the template correctly.

not valid template – the template you chose is not the correct one. Most likely the ID does not correspond to the right one. Our system is not detecting the variables you declared in our API call in the template, so you should first check if the template’s ID is correct.

unknown node ## near ## – There is a syntax error in the template. You should check if you have declared all the loops in template language sections.

“var:firstname” is not an array value – This error is generally returned when you try to loop on a non-array value. If you set up a loop as this {% for fn in var:firstname %}, you should declare something like this in your API call: {“firstname”:[“Jane”,”Joe”]}. If this is not declared, our system cannot compile the variables.

No value for “var:items” – you haven’t set up the variable in your API call. If a variable is not declared, our system is not able to replace it in the template with the corresponding value. We don’t want to send a template with {{var:items}} in it, because the recipient wouldn’t know what this should be.

expression parsing error ## Unknown identifier: var:day ## near ## {{var:day ## – This error indicates that the “day” variable is not defined in your Vars. It can be fixed by adding the default value for the variable or making sure that you pass all the variables required by the template.

expression parsing error ## Unknown identifier: day ## near ## {{day ## – This error is similar to the previous one, except for the absence of namespace (var or data). It can indicate that you forgot to specify whether you want to use a Send API variable var:day or a contact property data:day. It can also indicate that you are trying to use a template variable that is not defined in a set function nor a loop statement.

not valid template ## near ## y}} ## – This error occurs when the statement is not finished – missing {% endif %}

What should you do when you receive ## Unknown identifier: var:day ## near ## {{var:day ##, but you don’t see such variable in your template?Well… did you update the plain text version of the template? If the plain text version of the template is not updated, it still contains all the old variables and our system is still trying to compile them. This is why it is better to use our template error reporting. It is much easier for you to manage your templates and to fix some small errors that happened for any given reason.

Template Error Deliver

This second option determines if the message should – or should not – be delivered to the recipient in case of an error while processing the message’s template language. If the below line is not added in your API call, our system will assume this option is not enabled by default:

"TemplateErrorDeliver": true

What does it mean? If you don’t have this small code in your API call, in case there is any error in your template, the email won’t send. Our system will detect the error, it will send you an email with the error report (if you have switched on the Template Error Reporting option of course), and it will not proceed with the sending of the template to your recipients.

However, if you are still in the testing phase, it might be helpful to have this activated. If there is an error in your template, you will receive the error reporting, but you will also receive the uncompiled template itself. Our system will detect the error and will send you the error report email. However, our system will also see that the Template Error Deliver is active and it will send the emails anyways, just as they are.

So the recipient will see all the loops and variables without them being replaced with the data you set up in your API call. Yes, the template won’t look as pretty as it should (and as you and your great design team created it), but it will give you some general idea on how the template will look.

If you want to avoid any errors once your templates are in production, it would be better to remove “TemplateErrorDeliver”: true from your API call. You won’t risk having your template delivered, which will avoid any confusion from your contacts.

template-error-deliver

It is still helpful, though, to keep the Template Error Reporting element active so you can receive an email if there is something wrong with your template.

Template Error Management helps you resolve all issues with the template language in your email templates without losing a lot of time and nerves. Our dedicated API support is always here to help you resolve your issues, if you need any additional help identifying the problem or understanding the error you received via email.

If you want to be the first to get the next useful tips we are going to publish, follow us on Twitter and Facebook. Make sure not to miss a thing!

How To Code An Abandoned Cart Email With MJML

You know how many customers are leaving some items in their carts without processing to the actual purchase? We’re here to make sure you’re ready to give your customers that extra nudge and remind them about those items they once left behind in their carts. Even better you are going to make them even happier, by telling them that those items are on sale. 😏

If you’re a thorough follower of our tutorials, you may already know that, we’re showing you how to create and send awesome transactional emails step by step. We’ve already showed you how to create welcome email and email receipt using template language and MJML. Now, you’ll learn how to create abandoned cart emails.

A templating language for your transactional emails

Are you tired of creating a separate template for all your needs? Template language is here to offer you the best solution! You’ll be able to create one template for all your purposes using our template language.

Template language is available in different languages and using multiple libraries, so you are probably familiar with at least one of them. It’ll be a piece of cake! 😉

Mailjet’s Templating Language

At Mailjet, we know the value of a fully integrated templating language, which is why we created our own templating language with our Transactional Send API in mind. We’re here to help you manage everything in one template, to save you time and effort.

So, let’s recap: MJML for producing responsive HTML emails without effort, plus a templating language to bring them to life with conditional blocks and variables.
This combo can change your life as a developer. But, enough words, you’ll definitely want some action. That’s why we’ve decided to show you how to create and send awesome transactional emails, step by step.

The “How to code” tutorial: what you need to know

We’re rolling out a series of tutorials, all of which will explore a very common use-case, providing numerous examples, code snippets and nice visuals. We’ve even created an easy-to-execute tool, written with NodeJS, to test emails under actual conditions. To use it, you’ll just need valid credentials for both MJML API and Mailjet Transactional Send API, but don’t worry if you’re a newcomer: applying for the MJML API beta and creating a Mailjet account are totally free.

Our “How To Code” series has four parts. Check them out now:

How to code an abandoned cart: Quick Introduction

Today, we’re going to see how to implement an efficient abandoned cart email using MJML, the open-source email framework with 7600+ stars on Github open-source email framework, and our templatе language. Here’s a quick preview:

abandoned-cart-preview

When a customer adds products to their cart but doesn’t check out, it doesn’t mean the sale is definitively over. Here are some numbers for you: 50% of abandoned cart emails are opened, and more than a third of them trigger clicks to redirect customers to the website. And these figures could be even higher during a sale, when you’ll have the chance to offer your customers that additional tempting discount.

This high rate can be easily explained: customers often abandon their carts without meaning to do so, be it because of website crashes or times out (sure, that never happens to yours), or simply because they needed some time to think. This is why an abandoned cart email can be a successful way to re-engage customers, guide them through to the last step in your buying process or allow them to recover lost purchases.

A proper abandoned cart email should include the following:

  1. The items left in the cart.
  2. An incentive, such as a discount or a special deal, personalized for your user.
  3. Some new articles your user may prefer.

Let’s focus on these points.

How to create an abandoned cart email

You should encourage your clients to resume their shopping experience, just where they left it. This implies that your email template should display the abandoned cart, just as it looks on your website, both in terms of design and in terms of the items left behind. Easy to say when you’re using the [name here any trendy JS framework], but how do you do this in an email? The solution: use our templating language loops and variables directly into your email to display a cart based on raw JSON data.

Coding the abandoned cart section

Let’s start from the top of the template. We are going to use mj-navbar as container. We’ll choose this container as it is better suited for our needs and it’s already formed by two mj-column. The first one will contain mj-image and the other one the mj-inline-links component, which will create your links based on a list of mj-link children.

Of course we are going to add some CSS code to make our template prettier and here’s what we have:

Coding the body of the template

Now, let’s see how to code the main body of the template. As a general rule, it is recommended to keep it as close as possible to your cart’s main design on the website. Here’s our code:

As you can see, we’re using two nested mj-section. We’ll do this because the MJML API we’re using for this tutorial does not support the component yet.

Defining the items in the cart

Next, we’re going to configure everything related to the items in the cart. To do so, we are going to set up this loop {% for single_element in array_variable %}, using the following pattern: {{ var:property_key:default_value }}. Within the loop, a new variable single_element is created and updated for each iteration, ready to be used.
Here’s the MJML code for the display:

If you want to know how to set up your API call, visit our documentation here.

Coding the section with the additional discount

We are almost done! Now we need to let our customers know the good news! There are sales, oh surprise, the items that they left behind are now with discount! Who doesn’t love discounts? Probably some customers abandon their carts because they initially thought your products were cheaper. Hold on… Where did all these taxes and shipping fees come from? Well now, with the discount on the items, the customers won’t even notice those additional costs.
Here again, we’ll use a mj-table to display two sub-columns:

To win these customers back, the best way is to issue a discount or offer them free shipping, in the form of a deal that looks as if it was directly branded for them. To do this, add blocks to your template that only show up under specific conditions. In this tutorial, conditional blocks come to the rescue.

How to code section with other suggestion

Abandoned cart emails can provide a nice opportunity to present other products. You surely have a nice algorithm for recommendations – use it to generate some JSON data and, with our templating language, display nice personalized blocks directly in your email.

How to code CTA button

This is the easiest part. 😉 To add the CTA button, just use the code below for the mj-button:

Time to jump on Github

OK, we’ve given you an overview and some code examples to create an amazing abandoned cart email. Now it’s time to create your own with your own design.
You’ll find everything you need on our detailed tutorial on Github, complete with examples and code samples.

Github-tutorial-blogpost-banner 4

Have you missed the previous tutorials? Check them out here:

How to create an e-commerce receipt email

How to send a welcome series email

We’ve also created an easy-to-execute tool, written with NodeJS, to test emails under actual conditions. To use it, you’ll just need valid credentials for both the MJML API and Mailjet’s Transactional Send API. Don’t worry if you’re a newcomer: applying to the MJML API beta and creating a Mailjet account are totally free.

Do you want to be informed about the next tutorials? Come and say “hi” on Twitter or join us for a chat on Facebook

How to Use Templating Language to Send Truly Personalized Emails

Dear {{var:name}},

Wouldn’t it be cool to read an article that actually starts with your name? It would certainly grab your attention.

Well, what still sounds like a distant fantasy for the Mailjet blog is definitely a possibility for your emails using a template language.

If you’re not familiar with it yet, this post will tell you all you need to know to turn the template language function into your new email best friend.

What is template language?

A template language is a language that allows you to define placeholders within your templates that will be personalized depending on a set of variables or property details. Modern template languages don’t only support placeholders, but also loops and conditions that are often necessary to design a web page or an email.

Everyone likes to feel a personal touch in the emails they receive. It’s like if someone had thought about what you’d like to see, and had handpicked the perfect items or information just for you. We are not only talking about including a client’s first name, but using all kind of conditions, loops and functions to display content based on the recipient’s interests.

You’re probably already receiving these personalized emails while playing World of Warcraft, probably from Blizzard alerting you about the new great promotion on ingame items. So why not doing for your business too? It’s actually pretty easy to do, and email personalization usually increases the open rate by over 30%.

For example, say you have a sport e-store. You could send golfer Frank an email with all your new golf sticks, while tennis-player Diane would receive a message featuring the best tennis rackets.

If you are wondering how much is too much personalization, worry not – there is no such thing! Anything that’s personalized in the email will draw the recipient’s attention. And if you are showing them the perfect items, this will for sure generate more visits and purchases on your site. Think about your email as an invitation to check out what you found for them.

Why should you use Template language?

By using a template language for your transactional emails, you’ll be able to work with fewer templates, which will include different sections that will be displayed depending on the situation. Yes, you’ll still need a different template for account creation and for password reset, but there is no need to have five separate ones for each language you work with, for example.

Using Template language, you can add different sections for each language you need in one same template or propose a range of products for men and women in your order confirmation emails, using sections that display based on the client’s language or gender. Our system will collaborate with yours and show the appropriate option, depending on the customer’s properties defined as a variables in the API call.

Give it a try and see the magic behind the template language – you’ll never want to go back to working on 100 different emails for hours (or days…)!

How to use Mailjet’s template language?

Template languages and libraries are available for many programming languages, and choosing a language for your current needs is not difficult.

Mailjet’s Template Language follows a syntax close to the one used by the most popular template languages, such as Jinja2 or Twig, which means you’ll already be familiar with it. We made is easy and logical so even non-programmers can use it. 😉

Mailjet’s Template Language offers the perfect balance between power and ease.

You can apply it to your transactional emails using our awesome API, our collaborative editor Passport, MJML or HTML.

Mailjet’s template language can be used with IF conditions and FOR loops (wrapped between {% … %} delimitators) and supports the following operators:

  • Arithmetic operators,
  • Comparison operators,
  • Logical operators.

To learn more about which ones you can use and how to add them, check out our documentation here.

Let’s get practical: Applying high personalization with templating language in Mailjet’s builder

We know you’re probably keen to learn how it works, so let’s see how you could use some basic template language functions in Passport, Mailjet’s intuitive email builder, and then declare the variables in your API call.

Step 1: Creating the template

To get started, first create the template you need. In our example, we’ll work with an order confirmation.

Let’s say that Diane bought one of the tennis rackets you sent her (hooray!) and now you want to:

  1. Confirm her order.
  2. Show her items that she could also like.
  3. Give her an additional discount for her next purchase, which you normally do after a client’s third purchase.

This is the information we already have about Diane in our database:

First Name: Diane
Age: 28
Sports: Tennis
Number of purchases: 3

So, to get started, we’ll choose a template from Mailjet’s template gallery, add our logo and create our copy, with variables that we can set up, even without the template language.

This is what the template would look like:

order confirmation - first part

As you can see above, we’ve used these variables: {{var:ordernumber}}, {{var:firstname}}, {{var:product}} and {{var:companyname}}.

Step 2: Adding order details with Mailjet’s Template Language

So now for the fun part – using Mailjet’s Template Language. Just drag and drop the template language section wherever you want within the template, like this:

how-to-use-template-language-section

It might look like a boring section now, but not for long.

To display all the details of the purchased item and add new product proposals for Diane, you just need to click on the < > brackets that will show up when you select the section. A new window will open so you can add the code.

In the first section we are going to add {% for %} statement that will include an array of variables with all the details about the purchase. In our case it will look like this:

{% for article in var:products %}
{{ article.name }}
{{article.number}}
{{article.price}}
{{article.totalprice}}
{% endfor%}

You can choose the style and declare it as you wish in the same window in which you set up the loop.

Step 3: Displaying product recommendations

We are going to add a second template language section now. Let’s use one of our editor’s cool features and choose a section that should only be displayed to customers with that have added tennis as their favorite sport.

It’s actually pretty easy to do this. You just need to click on the section you want to apply the personalization to, and the option will appear in the upper left corner. This is an easy way to use an IF conditions for whole section.

template-language-section-condition

Now, click on “Add condition” and configure the right option for your specific use case. Here’s ours:

condition-section-template-language

Here, we’ll add the array of variables to be shown to customers that have marked tennis as their favorite sport:

{% for line in var:suggestions %}
{% for product in line %}
{{product.name}}
{{product.price}}
{% endfor %}
{% endfor %}

You can add as many of these sections as you want, based on everyone’s favorite sport, but you should also set a section without any conditions in which you include some basic suggestions for those that haven’t specified a favorite sport.

Step 4 – Adding shipping and billing information

Next, you want to add a new section with the billing information and shipping details, in two columns. This is what the section will look like:

template-language-billing-section

Step 5 – Including a discount

Finally, we’ll add a section offering Diane her and we are going to thank her:

template-language-thank-you-section

And here is the whole template we created together:

template-languae-order-confirmation-code

Step 6 – Syncing Mailjet’s Template Language with your system

We’re nearly there.
Below you can see the API call we’ll use to turn this rather plain template into a really cool confirmation email.
Here’s where we need your system to be involved. You’ll have to create a script on your end that will fill out all the variables with the all information you have about Diane and about your products.

curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3.1/send \
    -H 'Content-Type: application/json' \
    -d {
        "Messages":[
                {
                        "From": {
                                "Email": "youremail@yourdmaint.com",
                                "Name": "Your Name"
                        },
                        "To": [
                                {
                                        "Email": "recipeintemail@domain.com",
                                        "Name": "Recipient Name"
                                }
                        ],
                        "Variables": {
                        "ordernumber": "#12345",
                        "firstname": "Diane",
                        "product": "Tennis Racket",
                        "companyname": "Sport",
                        "products":[
			{
			"name": "Product: Tennis Racket",
			"number":  "Quantity: 1",
			"price": "Price : $30.00",
			"totalprice":"Total Price: $30.00"
			}
			],
	"suggestions": [
		[
			{
			"img": "",
			"name":  "Product: Tennis skirt",
			"price": "Price: 23€"		
			},
			{
			"img": "",
			"name": "Product:  Tennis bag",
			"price":  "Price: 45€"
			},
			{
			"img": "",
			"name": "Product: Tennis balls",
			"price": "Price: 8€"
			}
		]
		],
		"billingfull_name": "Adress: Your address",
		"billing_city": "City: Paris",
		"billing_addresspostal_code": "Postal code: 75008",
		"shippingfull_name": "Adress: Your address",
		"shipping_city": "City: Paris",
		"shipping_addresspostal_code": "Postal code: 75008",
		"discount": "10%",
		"Sport": "tennis"
                        },
                        "TemplateID": 123,
                        "TemplateLanguage": true,
                        "TemplateErrorReporting": {
					"Email": "youremail@yourdmaint.com",
                              			 "Name": "Your Name"
				},
                        "Subject": "Order confirmation"
                }
        ]
    }

Once that’s done, you can add some finishing touches to the template and voilà, all is done and the email is ready to be sent. Here’s what Diane will receive:

template-language-final-email

Looks great right? Now you know how to create amazing templates like this one with Mailjet. 😏 And soon, we’ll show you how to do this with HTML and more advanced functionalities of our template language, so you can take this to the next level.

Wrapping up:

We’ve explained the wonders of using a template language and shown you how to create an order confirmation email with Mailjet’s Template Language and our email editor, Passport.

But there’s so much more you can do! This dynamic duo will help you create amazing account confirmation emails, password reset emails, abandoned cart notifications, etc. Keep an eye out for our next posts, in which we’ll show you how to do just that, using the template language in Passport, or applying it on MJML or HTML.

And… don’t forget to follow us on Twitter and join us on Facebook as well! We are always happy to hear your ideas and comments. :)

How to Set Up a Double Opt-In Subscription Form via Mailjet’s API

Deliverability is a pain. We know it.

That’s why, here at Mailjet, we are doing our best to get your emails straight into the inbox, but we need your help as well. We know that you want this too, in order to consistently generate more visits to your site.

While Mailjet can provide a solid infrastructure, industry leading deliverability tools, and a team devoted to you deliverability, your role in this partnership is to ensure 100% of your list has opted-in to receive communications. Because they have, haven’t they? 😉

Opt in for best deliverability

Opt-in subscription forms can be used to capture contact information from customers and visitors in a variety of ways: pop-up forms on the homepage or product pages, dedicated landing pages, and embedded widgets across your website.

A customer subscribing on your platform is like a verbal confirmation of interest in receiving your communications, however a double opt-in subscriber is like getting their signature. Not only does it really prove their consent, but it also is indicative that they really want to engage with your content, products, or services. These are the most valuable contacts.

single opt-in vs double opt-in

Single opt-in vs Double opt-in

There are two types of opt-ins – single and double. While the single opt-in only requires users to provide their email address in one step, the double opt-in widget includes two steps to confirm the subscription. Single opt-in subscriptions skips a crucial second step – confirmation. Side note: Stay tuned for our next article where will explain more about the differences between single and double opt-in.

Why is double opt-in better?

This validation process consists of receiving an email with a custom confirmation link.This will guarantee that the address is in fact valid and it’s owner agrees to receive your marketing campaigns. It eliminates the chance of abuse where somebody submits somebody else’s email address without their knowledge and against their will. At the same time, typos in email addresses are also caught, as are the risk of bots mass subscribing to your content.

By using double opt-in you can reduce spam complaints down to well within acceptable levels (e.g. at Mailjet we make sure our users do not get more thank 0.08% spam complaints).. While double opt-in is not obligatory by law yet, the GDPR is still requesting valid and unambiguous consent for subscription.

GDPR double opt-in

Often quality is better than quantity, and this is certainly the case in emailing. You will have very strong deliverability rates and you will know your audience will be anticipating and willing to read your newsletters. This sure beats sending emails to addresses with typos, bots, or fake accounts.

How to set up a double opt-in through Mailjet’s API

By now hopefully we have convinced you that it is far better for you to use a double opt-in subscription widget, so now we are going to explain how to create one through our API. This is a good solution if you already have an existing opt-in and you just want to connect it to Mailjet, or if you think using our subscription widget is just… too easy for you. 😏

In the diagram below you can see a schema of the process and the steps to follow to make the connection between your system and ours through our API:

Now, let’s have a look at the different steps.

Blog-Double-Opt-In-Schema

Step 1 – Contact’s subscription

Lucky you! Your visitor has decided to subscribe to one or more newsletters via an opt-in on your site.

This form can also contain additional contact properties (like first name, last name, city, gender, etc.). Basically, anything you find useful later to segment your list or personalize your newsletter.

Step 2 – Creation of the customized confirmation link

When the user completes the subscription form, the email address and contact properties will be saved on your system. Then you will have to generate the custom confirmation link that should be send to the client by email. This custom URL should guarantee that the subscription cannot be faked and only the person you are addressing can click on it.

For example you can use MD5 hash algorithm to convert the name of the recipient to 128-bit hash value. Then you could insert it as a variable at the end of the confirmation link. Your system will perform a MD5​ of the email address concatenated to a specific SecretKey​ which will be corresponding to the custom URL.

 http://mysystem.com?{{var:Email​OfTheUser}}&{{var:MD5hash}}

 

Step 3 – Sending of the confirmation email

After your system creates the customized confirmation link, it is time to leverage our Send API through a POST request. You should create a template for the confirmation email that will contain the custom URL. You can design the template with our intuitive email builder, Passport, or via our API using Mailjet’s templating language. You can insert the confirmation link behind a button or just as it is. Below you can see an example of an API call that you can use:

# This call sends a message to one recipient.
curl -s \
-X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3.1/send \
-H 'Content-Type: application/json’ \
-d ‘{
    "Messages":[
            {
                        "From": {
                                 "Email": "sender@email.com",
                                 "Name": "Sender Name"
                        },
                        "To": [
                                {
                                     "Email": "recipient@email.com, 
                                     "Name": "Recipient Name"
                                }
                        ],
                        "Variables": {
                                "MD5hash": "MD5hash",
                                 "EmailOfTheUser": "EmailOfTheUser"
                        },
                        "TemplateLanguage": true,
                        "Subject": "The subject you want", 
                        "TextPart": "Welcome to our mailing list! Please activate your subscription by clicking in this link: 
http://mysystem.com?{{var:EmailOfTheUser}}&{{var:MD5hash}}", 
                        "HTMLPart": "Welcome to our mailing list! Please activate your subscription by clicking in this link: 
http://mysystem.com?{{var:EmailOfTheUser}}&{{var:MD5hash}}" 
                       } 
           ]
   }’

 

Step 4 – Creation of template

If you want to use an awesome template you created with our email editor, Passport, or with MJML / HTML code, you can send it easily with the API, by following the steps here or using the example below:

curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3.1/send \
    -H 'Content-Type: application/json' \
    -d '{
        "Messages":[
                {
                        "From": {
                                "Email": "sender@email.com",
                                "Name": "Sender Name"
                        },
                        "To": [
                                {
                                        "Email": "recipient@email.com",
                                        "Name": "Recipient Name"
                                }
                        ],
                                "Variables": {
                                "MD5hash":“MD5hash",
                                       "EmailOfTheUser": "EmailOfTheUser"
},
                         "TemplateLanguage": true,
                         "TemplateID": 123,
                         "Subject": "The subject you want to use"
                          }
                 ]         
             }'

 

Step 5 – Customer’s confirmation

At this step, the action should be completed by your customer. They are going to receive your email and they will have to click on the confirmation link in it.

Step 6 – Adding and sync of the contact

The user has done their part and that means that they are ready to be added to your contact list. Now a confirmation page should be displayed to them thanking them for their subscription.

The opening of this page should refer back to your system with the appropriate parameters (email and MD5 hash). They will give you the MD5 checksum (Secret Key) corresponding to the confirmation link associated with this user. If the parameters are correct, the contact will be added in your system.

MD5 checksum == EmailOfTheUser + MD5 hash value

Example:
Recipient Name: John Smith and recipient email johnsmith@email.com

Secret key in your system == johnsmith@email.com + 6117323d2cabbc17d44c2b44587f682c

Step 7 – Adding customer’s properties

Only one thing left to do – add the client to the list and attribute the properties they provided. This can be done by your system which should call Manage Contacts endpoint of our API.

Here’s an example of the request:

 # Add a contact to the list
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/contactslist/$LIST_ID/managecontact \
    -H 'Content-Type: application/json' \
    -d '{
        "Email":"recipeint@email.com",
        "Name":"Recipient Name",
        "Action":"addnoforce",
        "Properties":{
                "property1": "value",
                "propertyN": "valueN"
        }
    }'

 

Important: If your contact specified some properties, you should make sure you have defined those properties in advance in the Mailjet system with the user interface or with the API.

# Create : Definition of available extra data items for contacts.
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/contactmetadata \
    -H 'Content-Type: application/json' \
    -d '{
        "Datatype":"str",
        "Name":"Age",
        "NameSpace":"static"
    }'

 

And with that, it is all done!

Collaboration Toolkit

Summing up

We’re sure by now, you’re convinced double opt-in is the way to go to ensure you’re only sending emails to contacts that really want to receive them, and to ensure optimal deliverability.

Once you have created your widget and configured the scripts to sync your contacts with with Mailjet, you’re ready to start sending. From now on, any contact that enters your database and confirms their subscription will become part of your list at Mailjet, with all of the properties they declared.

Now you can continue with the creation of your awesome campaigns to send to all those new subscribers. You can see how to do so here.

Share your thoughts and ideas with us on Twitter and Facebook, and follow us to be the first to get the news!

How To Code A Welcome Email With MJML

You already know we’re working on a series of tutorials to show you how to create and send awesome transactional emails step by step, using MJML, our open-source email framework, and Mailjet’s templating language. Each tutorial covers a very common use-case, providing a large set of examples, code snippets, and nice visuals.

Today, we’re going to see how to implement an efficient welcome email. Here’s what you’ll find in this post.

 

A templating language for your transactional emails

You already know that flexibility and personalization are a must-have in the email industry. Transactional emails imply more and more complex business logic, and one can often struggle to try to juggle a lot of different templates, when they could just have one personalized email that adapts to several use cases.

Having a separate template for men and another one for women, or creating specific campaigns to recommend different things based on your customer’s previous purchases is not viable. It is in this kind of situations that a templating language comes in handy.

Even if you could potentially write your own, to be able to implement a tokenizer and a grammar, you’d need to have a good knowledge in the field and might end up reinventing the wheel when you could have been focusing on your core business instead…

You could instead use nice libraries such as Handlebars, Jinja or Twig, but then you’ll still need to write or host a dedicated service to handle the templating processing.

Mailjet’s Templating Language

At Mailjet, we know the value of a fully integrated templating language, which is why we created our own templating language with our Transactional Send API in mind. Our idea: one template to rule them all, just with a single API call.

So, let’s recap: MJML for producing responsive HTML emails without effort, plus a templating language to bring them to life with conditional blocks and variables.

This combo can change your life as a developer. But, enough words, you’ll definitely want some action. That’s why we’ve decided to show you how to create and send awesome transactional emails, step by step.

 

The “How to code” tutorial: what you need to know

We’re rolling out a series of tutorials, all of which will explore a very common use-case, providing numerous examples, code snippets and nice visuals. We’ve even created an easy-to-execute tool, written with NodeJS, to test emails under actual conditions. To use it, you’ll just need valid credentials for both MJML API and Mailjet Transactional Send API, but don’t worry if you’re a newcomer: applying for the MJML API beta and creating a Mailjet account are totally free.

Our “How To Code” series has four parts. Check them out now:

 

How to code a welcome email: Quick Introduction

We know you are an email veteran, and the double opt-in has no more secrets for you. So, during the signup process, you asked your user to confirm their email address. This verification step is now over. You can open yet another bottle of champagne, you have one true new user interested in your product. Congratulations.

But then you start to wonder. It could be that users browse your website right now, or come back later. And you know people. Chances are, they’ll have other things to do, they’ll forget and never come back. So you need to grab their attention again. Why not use the valid email address they offered you willingly?

Welcome emails are indeed a powerful way to communicate because users are expecting them. When you enter a store as a consumer, you expect friendly greetings, useful information or good advice. While this behavior is common for most customers, that doesn’t imply they’re all the same. It is important to take your user’s tastes or habits into account, in order to create relevant messages. We can see you starting to panic: how many templates would you have to write?

Don’t freak out! Leveraging the power of our templating language, we will show you how to create a customized welcome series, using only a single template. In this tutorial, we will show you how to:

  1. Create blocks that display different elements according to your user data (location, gender… think segmentation!).
  2. Set a templating language variable and leverage it to display personalized data.
  3. Use templating language functions to transform text.

Example: welcome email

 

How to code a welcome email template: Over to Github!

Looking for some extra help in coding your welcome emails? You’re in the right place. We’ll tackle all the points above, and more, in our dedicated Github tutorial for coding welcome email templates with MJML.

Our Github tutorial includes:

  • Clear explanations.
  • Code samples you can use while working on your welcome emails.
  • Examples of a welcome emails and its different parts.

Ready to start writing an awesome welcome email template?

Time to jump over to Github.

Jump over to our Github tutorial for welcome emails!


We’ve also created an easy-to-execute tool written with NodeJS to test emails under real conditions. To use it, you’ll just need valid credentials for both MJML API and Mailjet Transactional Send API, but don’t worry if you’re a newcomer – applying to join the MJML API beta and creating a Mailjet account are totally free.

Want to say “hi” to the team? Come and chat with us on Twitter.

How To Code An Email Receipt Template With MJML

We are developers, like you. And what we hate above all in coding is to repeat ourselves. So when it comes to writing email templates, we want to provide our users with the best tools to produce content in the most efficient way possible, whether you want to know how to code an e-receipt or just update your welcome emails.

To speed up the development of responsive emails, we’ve already told you about MJML, the open-source email framework we’ve created. If you’re not familiar with it, go check it out right away. You can thank us later.

But even if MJML can help you save quite a lot of time and ease the process, you’ll probably want more. We hear you.

 

A templating language for your transactional emails

Today, flexibility and personalization are a must-have in the email industry. Transactional emails imply more and more complex business logic, and one can often struggle to try to juggle a lot of different templates, when they could just have one personalized email that adapts to several use cases.

Having a separate template for men and another one for women, or creating specific campaigns to recommend different things based on your customer’s previous purchases is not viable. It is in this kind of situations that a templating language comes in handy.

OK, let’s be a bit naive and accept that you could write your own. But to be able to implement a tokenizer and a grammar, you need to have a good knowledge in the field and, at the end of the day, you might just be reinventing the wheel when you could have been focusing on your core business instead…

You could instead use nice libraries such as Handlebars, Jinja or Twig, but then you’ll still need to write or host a dedicated service to handle the templating processing.

Mailjet’s Templating Language

We have the solution. Because at Mailjet we know the value of a fully integrated templating language, we created our own templating language with our Transactional Send API in mind. Our idea: one template to rule them all, just with a single API call.

So, let’s recap: MJML for producing responsive HTML emails without effort, plus a templating language to bring them to life with conditional blocks and variables.

This combo can change your life as a developer. But, enough words, you’ll definitely want some action. So we’ve decided to show you how to create and send awesome transactional emails, step by step.

 

The “How to code” tutorial: what you need to know

We’re rolling out a series of tutorials, all of which will explore a very common use-case, providing numerous examples, code snippets and nice visuals. We’ve even created an easy-to-execute tool, written with NodeJS, to test emails under actual conditions. To use it, you’ll just need valid credentials for both MJML API and Mailjet Transactional Send API, but don’t worry if you’re a newcomer: applying for the MJML API beta and creating a Mailjet account are totally free.

Our “How To Code” series has four parts. Check them out now:

 

How to code a receipt email template: Quick Introduction

From online shoe stores to indie music platforms, any company selling a product online will have to send a receipt. You may think this is a simple task but, actually, there are several elements you’ll need to consider.

Let’s review them briefly, before jumping over to our tutorial, from the more obvious ones to the less:

  1. You will have to loop over the list of items (cart, abandoned cart, recommendations, etc.) and display them.
  2. You need to display the price and may have to do some calculus directly in the email logic (Total, VAT and other taxes). Be careful, as you may use different currencies!
  3. You need to include some basic billing information (billing address, order number, etc.), but you can also provide more personalized information (for instance, you could warn your users that their registered credit card is about to expire).
  4. If there’s shipping, you should display the delivery address.
  5. Your user may have to forward the e-receipt for accounting purposes, so you should ease this workflow.
  6. You can insert marketing content to your receipt, such as a history of previous items or new promotions based on what your user just bought.
  7. If your website supports multiple languages, your emails should too.

Preview of the receipt email template

 

How to code a receipt email template: Over to Github!

Sounds like something you’re already doing? Or are you not sure how to implement some of these elements?

Worry not, we’ll tackle all these needs, and more, in our dedicated Github tutorial for coding email receipt templates with MJML.

On our Github tutorial you’ll find:

  • Detailed explanations.
  • Code samples to implement and adapt.
  • Examples of a receipt email and its different parts.

Ready to see it in action?

Time to jump over to Github.

Github tutorial: How to code a receipt email

 

Embrace Mailjet’s New Multi-Channel Experience With SMS API

Well, fellow API enthusiasts, we just launched something new that should get your attention. Something that pairs perfectly with email. Something that opens up new doors for an improved customer relationship. Something that we, as a transactional solution leader, needed to bring: Short Text Messaging!

Commonly known by the sweet name SMS, it’s one of the most efficient channels of communication that can boost your contact engagement!

As an API wizard, there are two main factors that you usually consider: how useful is this new integration, and how easy is it to implement? We take both these factors into account when developing API solutions, and so after months of hard work, here comes the newest one – our SMS API. This is a feature for those who love simple and effective APIs, allowing you to send SMS all around the world in just 5 lines of code!

Right now, this release is focused on transactional messages, but we aim to evolve these features with new components in the future. As a developer, if you see room for improvement and ways to collaborate with us, your feedback will help us make this feature even greater!

 

So, why is the SMS API useful to you?

Text messaging is one of the most impactful channels for direct communication. According to the Mobilesquared report, 90% of SMS are opened and read within 3 minutes after reception, and 72% of users are interested in receiving transactional SMS.

Given these figures, SMS sending presents a huge opportunity for businesses to engage with their clients.

For instance, you may want to increase security by enabling two-factor authentication for your users, send them useful notifications to increase customer engagement, or display payment confirmations on their phones to verify successful transactions. All of the above benefit from instant sending and a quick way of viewing the messages – and what is quicker than checking your phone to see the SMS you just received?

 

Any requirements before I start sending?

To send SMS messages, you need two things – funds in your SMS wallet and a Bearer token to authenticate your requests.

Token authentication is a different method from the one used for emails, but just as easy. Simply create your token in the front-end, then use the token value in the Authorization header of your payload. For security purposes we don’t keep the token values – once you create it, you need to copy it locally in order to use it.

 

Generate Bearer Token for SMS

 

Time for some code, don’t you think?

We’ve talked enough about the benefits of sending transactional SMS – it’s time to see how it’s done, and what else is possible with Mailjet’s SMS API!

 

Send your SMS

Sending an SMS message is done with a simple HTTP call on the /sms-send endpoint. The payload consists of a JSON body with 3 properties – To (recipient’s phone number), From (customizable sender ID) and Text (the message content).

Nothing to it, right?

 

Detailed Error and Success Payloads

In order to help you quickly find sending issues, we implemented strict checks on your input payload. This means you’ll get synchronous feedback on what went wrong, scaling down your debugging time. See the below example of an error payload:

The success reporting is also quite detailed, providing information about, among other things, the message sender and recipient, Status and Cost.

 

What about Statistics?

You can easily retrieve lists of SMS messages with an HTTP call on the /sms endpoint. You can filter by message delivery status, recipient’s phone number, time period etc.

The response will include a list of messages matching the conditions you have set with the filter values, starting from the most recently created one.

In case you only need the count of the messages, use the /sms/count endpoint instead, and the response will show the number of messages matching your filter settings.

You will also be able to export lists of messages using the /sms/export endpoint.

 

Where can I learn more?

See our dedicated SMS API Guide to learn how to use its capabilities. And, of course, take a look at the SMS API Reference or detailed information on the endpoints, properties and available filters.

 

What’s Next

Glad you asked. Sending transactional messages is just the first step into the SMS world and the beginning of a long series of awesome developments for Mailjet’s API users. Here’s what is on the agenda for the next few months:

  • Beyond Transactional: Additional features to the V1 will allow you to book your own short code for sending SMS and MMS, as well as enhanced tracking and statistics.
  • Marketing campaigns: By building bridges between emails and SMS to manage your contacts or your marketing campaigns, you will be able to engage your customers in a new yet more accurate multichannel experience.
  • Conversational Messaging: 2-way SMS or the possibility to retrieve responses to any SMS you send with us will establish the bedrock for any automated marketing, chat apps or bots.