With SendinBlue, you can use "if..." conditions to personalize your email.
The powerful logic offered by if
conditions enables you to add or remove entire content blocks within your email or modify specific content within a block.
This means you can display different sets of content or text based on the contact attributes defined in your contact list, or based on the parameters passed in your API call. This effectively extends the usefulness of a single email for multiple scenarios.
Common uses for "IF" conditions
There are countless ways to use if
conditions to personalize content, but some of the most common are:
1. an email greeting, such as "Hello Mr. Smith", "Hello Mrs. Brown" or simply "Hello" for contacts without gender or name data on file
2. a product or promotional image, such as promoting an image of a model that wears the same clothing or size as your recipient, or displaying the featured item in their favorite color
3. a promotional message, such as including an extra marketing offer in your transactional emails based on their purchases or other attributes
Structuring your "IF" condition
Simple "IF" condition
An if
condition always starts with the tag {% if %}
and is always closed with the tag {% endif %}
. Everything within these two tags will be considered part of the condition.
When your if
condition contains only one option, such as "if this is true, display this content", you only need to open your condition with the {% if %}
tag and close it with the {% endif %}
tag.
For example, if your contact list includes a contact attribute called "MEMBER" and you include this statement in your email:
{% if contact.MEMBER %}
Thanks for renewing your membership!
{% endif %}
the content within the condition will appear in your email message if the attribute has any value in your contact list (e.g. "Thanks for renewing your membership!").
Detailed "if" condition
In addition to using if
conditions to check for true values or values that simply exist, you can also check for false values, or evaluate multiple conditions or multiple branches.
Following the common example of personalizing an email greeting, you may wish to display one of three possible greetings depending on whether the recipient's attribute for GENDER is Male, Female or empty.
In this case, you can use the tags {% elif %}
to add alternate content when the value for GENDER is Female, and {% else %}
to add a back-up for any other case.
Hello {% if contact.GENDER == "Male" %} Mr. {{ contact.LASTNAME }},
{% elif contact.GENDER == "Female" %} Ms. {{ contact.LASTNAME }},
{% else %} there, {% endif %}
Quickly build "IF" conditions in the Drag & Drop Editor
Simple or detailed if
conditions may be easily applied to an entire content block in the Drag & Drop Editor by using the built-in Conditional display tool. Learn more in this guide about conditional display.
Learn more about "IF" conditions
While these examples focused on structuring if
conditions with contact attributes, you may also apply these conditions to transactional parameters within the Drag & Drop Editor or by manually building them in your email. Learn more in these guides: