Go beyond one-size-fits-all emails and deliver hyper-personalized content that boosts engagement and drives conversions. With conditional clauses, you can dynamically change the text, images, and offers in your emails based on your customers' unique attributes and activities.
This guide will show you how to use IF, ELSE, and ELSEIF logic to create truly responsive and effective campaigns.
Best Practices for Using Conditionals in Links
- Avoid Placing Conditionals Inside URLs: To ensure your links work correctly, please avoid placing conditional logic directly within the URL of a content tag. Doing so can cause errors that may break your campaign.
- A Better Approach - Make the Whole Button Conditional: A more reliable method is to make the entire call-to-action (CTA) button conditional. For example, you can set up a rule that says, "If a customer meets a specific condition, show this entire button with its unique link; otherwise, show a different button with another link."
- Always Test Your Changes: We strongly recommend thoroughly testing any updates to your content tags before launching your campaign. Sending a test email to yourself is a great way to catch any potential issues and ensure everything works as expected.
How Conditional Clauses Work
Conditional clauses use simple logic to control what content a recipient sees. The system checks if a condition is true for a customer and displays content accordingly.
[%IF:condition%]...[%END:IF%]
Shows content only if the condition is met.
[%IF:condition%]...[%ELSE%]...[%END:IF%]
Shows one piece of content if the condition is met and a different piece if it's not.
[%IF:condition%]...[%ELSEIF:condition%]...[%ELSE%]...[%END:IF%]
Lets you check for multiple different conditions in a sequence.
How to Add Conditional Clauses
Whether you're using the Visual or HTML editor, the process is straightforward. The key is to wrap the content you want to show or hide within the conditional tags.
In the Visual Editor
- Drag a text content block into your template.
- Type your conditional tags directly into the block (e.g.,
[%IF:Country=='France'%]). - Add the content (text, images, buttons) you want to display if the condition is true.
- Close the statement with the appropriate tag (e.g.,
[%END:IF%]).
In the HTML Editor
- Place your cursor in the editor where you want to add the logic.
- Click the Conditional Language button in the editor toolbar. A window will appear with pre-made code snippets for different conditions (Simple, IF-ELSE, etc.).
- Choose the snippet that matches your needs to insert it into your template.
- Replace the placeholder values (like
YOUR_TAGandTEXT) with your actual customer attributes and the values you want to check for. - Ensure you place your content (text, images, HTML) in the "Content to display" sections.
Strategic Examples to Elevate Your Campaigns
Here’s how you can use conditional logic to achieve specific marketing goals.
Rewarding Loyalty with Tier-Based Offers
Encourage repeat purchases by showing different offers based on a customer's historic spending. This makes your top customers feel valued and entices others to climb the loyalty ladder.
Example Code:
[%IF:AvgOrderValue > 200%]
Enjoy 25% off your next order as a VIP!
[%ELSEIF:AvgOrderValue > 100%]
Here's 15% off, just for you.
[%ELSE%]
Get Free Shipping on your next purchase!
[%END:IF%]
Personalizing Welcome Messages for New vs. Returning Visitors
Create a great first impression by tailoring your message based on whether a customer has purchased before. A personalized welcome can significantly improve engagement.
Example Code:
[%IF:LifetimePurchases == 0%]
Welcome! Here's a special 10% discount to get you started.
[%ELSE%]
Welcome back, valued customer! Check out our latest arrivals.
[%END:IF%]
Handling Missing Data Gracefully (e.g., First Name)
Avoid awkward "Hello, null" greetings. Use conditional logic to provide a friendly, generic greeting when a first name isn't available in your data, ensuring a professional experience for everyone.
Example in a Subject Line:
[%IF:FirstName%]A special offer for [%FirstName%][%ELSE%]You Won't Want to Miss This Offer[%END:IF%]
Troubleshooting
If your clause isn’t working as expected, check for these common issues:
- Missing
[%END:IF%]Tag: Every conditional statement must be closed. You only need one[%END:IF%]at the very end of the entireIF/ELSEIF/ELSEblock. - Incorrect Operators: Make sure you're using the correct comparison operator. For checking equality, the operator is
==(double equals), not=(single equals). - Case Sensitivity: Values inside your conditions are case-sensitive.
'spain'is not the same as'Spain'.
Supported Operators Reference Table
| Operator | Meaning |
|---|---|
| No operator | True if the personalization tag has any value |
== |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |