Variables and conditions in email templates

One of the ways how to make newsletters and marketing emails feel more personal is to include details about the person receiving the email. You can greet them by their name and mention other details specific to your audience.

Hello {{ first_name }},

Here, we’re sending an email with a greeting that will be specific to each recipient. The square brackets mean that we want to output a variable called first_name. When sending the email, the whole expression including the square brackets will be replaced with an value of each subscriber’s first name.

The way you do this might differ in your email marketing app but the principle is the same - you use values stored for each subscriber and output it in the email. Consult your marketing app’s documentation how to do this. The examples here will all use SendingBee‘s syntax and features.

A common scenario when dealing with variables is that you don’t have a value for every subscriber. For example, you don’t know every subscriber’s first name. To handle this, you can use default values as follows.

Hello {{ first_name | default: "there" }},

When the email is being sent and a recipient is missing its first name, the system will replace it with the value specified in the default block. In this case the email will read “Hello there,” when the value is missing.

Sometimes you want to go further and show or hide entire paragraphs of text based on a subscriber’s variable values. For example, you might want to show an additional paragraph in case the subscriber has purchased at your shop more than 10 times.

{% if purchased_num_times > 10 %}
Thank you for being a loyal customer! Use our coupon...
{% else %}
Thank you for shopping with us.
{% endif %}

A speciality of SendingBee is the ability to conditionally show entire components. Clicking on a component reveals its settings and you can write conditions in the “Show If” input field.

Seeing whether an email with variables and conditions is correct can be difficult because you don’t see the email rendered. You can however do just that in SendingBee. At the top, you can search for a contact (subscriber) and once selected, the email will be rendered in the context of that particular user.

Going a step further, you can send yourself a preview of the email using the envelope icon right next to the “Preview as” input to see the email in a real email client.

Variables and conditions are essential tools in today’s marketing emails and you should invest some time into learning how to use them effectively. If you’re interested in using SendingBee while doing so, please sign up and do not hesitate to contact us in case you have any questions.