Looking for help with your list?
Mailchimp lists are now called audiences. They include the same data and functionality as before, along with valuable new insights about your contacts. As we introduce this change over time, you’ll notice fewer places where we still say list. Learn more about this change.
Conditional merge tag blocks insert dynamic content into your email campaigns. To show unique content to subscribers with different profiles, you'll need to create multiple versions of your content to display, then use conditional merge tag blocks in your campaign that reference the subscriber data stored in your audience.
When you send an email that uses conditional merge tag blocks, we'll display your unique content to just the subscribers who match the conditions.
In this article, you'll learn how conditional merge tag blocks work and how to use them.
Before You Start
Here are some things to know before you begin this process.
- If you have more than one Mailchimp audience, make sure you use the correct merge tags for the audience you plan to send to.
Conditional merge tags do not work in email subject lines or with unique URLs.
Conditional merge tag blocks can become complex very quickly, so be sure to test your campaign thoroughly. If you want to do something extensive, you may want to contact your developer or hire a Mailchimp expert if you need assistance.
Mailchimp conditional merge tag blocks support traditional IF statements, as well as these operators.
!=does not equal to
>=greater than or equal to
<=less than or equal to
Conditional merge tag statements will support IF, ELSE, ELSEIF, and IFNOT logic, as represented in this table.
|IF||Use IF to indicate the content to display if the *|MERGE|* tag value is true.||*|IF:MERGE|* content to display *|END:IF|*|
|ELSE||Use ELSE to indicate alternative content to display if the *|MERGE|* tag value is false.||*|IF:MERGE|* content to display *|ELSE:|* alternative content to display *|END:IF|*|
|ELSEIF||Use ELSEIF to specify a new *|MERGE|* tag to be matched against if the first *|MERGE|* tag value is false.||*|IF:TRANSACTIONS >= 20|* Enjoy this 40% off coupon! *|COUPON40|* *|ELSEIF:TRANSACTIONS >= 10|* Enjoy this 20% off coupon! *|COUPON20|* *|ELSE:|* Enjoy this 10% off coupon! *|COUPON10|* *|END:IF|*|
|IFNOT||Use IFNOT to indicate the content to display if the *|MERGE|* tag value is false.||*|IFNOT:MERGE|* content to display *|END:IF|*|
Conditional Block Format
Here are a few things to keep in mind when using conditional merge tag blocks in your campaigns.
- For the most consistent results, use number fields in your audience for >= greater than and other numerical comparisons. A text field that includes non-numerical values, like a period or comma, may not display the results as expected.
- IF logic checks against the entire string value in a statement, so AND conditions and OR conditions should not be used. For example, in the condition *|IF:MERGE OR BAR|*, the entire string, "MERGE OR BAR," would be checked, instead of treating "MERGE" and "BAR" as separate values.
Conditional merge tag blocks can do a lot, and you may want to include multiple blocks in your campaign. To help you see the tags clearly in these examples, we present the blocks line-by-line. But when you use multiple conditions in a campaign, remove the extra spaces to ensure your content is displayed correctly.
|Format in this article||Format required in your campaign|
|*|IF:MERGE=1|* Content 1 *|END:IF|* *|IF:MERGE=2|* Content 2 *|END:IF|*|
Conditional Merge Tag Block Examples
Here are a few common uses for conditional merge tag blocks.
Present Unique URLs for Each Subscriber
Create personalized campaign links for individual subscribers.
Translate Content for International Audiences
Display your content in different languages based on subscriber profile information.
*|IF:MC_LANGUAGE=es|* Spanish content here. *|ELSE:|* Display English content for everyone else. *|END:IF|*
Display Content When Data is Missing
Show a generic value in place of missing data. For example, you may want to have a greeting like "Hello *|FNAME|*," but not all of your recipients have an FNAME value in your audience.
Hello *|IF:FNAME|* *|FNAME|*, *|ELSE:|* Friend, *|END:IF|*
Display Information by State
Show different promotions to subscribers who live in California, Georgia, or other specific states. Remember to remove any spaces between your merge tags and content when you use multiple conditions in a statement.
*|IF:STATE=CA|* Save 20% on surf boards! *|END:IF|* *|IF:STATE=GA|* Save 20% on mountain bikes! *|END:IF|* *|IF:STATE=FL|* Save 40% on water skis! *|END:IF|* *|IF:STATE=CO|* Save 50% on ski gear! *|END:IF|*
Present Special Offers to Customers
Offer different coupons to frequent purchasers or customers whose recent purchases are over a certain amount. Pay special attention to the order of this code to ensure a subscriber doesn't meet multiple conditions.
First, set up a number field in your audience to keep track of how many purchases each subscriber makes, and import that data from your CRM into the Mailchimp field. Then use conditional merge tags to display different coupons that reward customers based on their purchase history.
*|IF:TRANSACTIONS >= 20|* Enjoy this 40% off coupon! *|COUPON40|* *|ELSEIF:TRANSACTIONS >= 10|* Enjoy this 20% off coupon! *|COUPON20|* *|ELSE:|* Enjoy this 10% off coupon! *|COUPON10|* *|END:IF|*
Hide or Display Content on Certain Pages
Hide or show parts of your content on campaign pages. This condition can be very useful if you send coupons or very time-specific content that you don't want to appear on your campaign page in the future.
*|IF:ARCHIVE_PAGE|* Content visible only on the sent campaign page. *|END:IF|*
*|IFNOT:ARCHIVE_PAGE|* Content visible only in the campaign. *|END:IF|*
Display Information Based on Age
*|IF:AGE >= 18|* Don't forget to vote this Tuesday! *|END:IF|*
Request Missing Information
*|IFNOT:FNAME|* Hey there! It looks like we're missing some information for you! Would you mind updating your profile? *|END:IF|*
Use Groups with Conditional Merge Tag Blocks
If you have groups in your audience, you can show conditional content to subscribers based on the group they're in. Instead of a merge tag, refer to the group category and names in your conditional block.
*|INTERESTED:GroupTitle:GroupName|* Content to display to group. *|END:INTERESTED|*
Group Category: Role
Group Name 1: Student
Group Name 2: Staff
Group Name 3: Faculty
To display content only to your Faculty group, your conditional merge tag block should look like this.
*|INTERESTED:Role:Faculty|* Thank you for your dedication to our students! *|END:INTERESTED|*
You can also create a conditional block to display content to subscribers who are not in specified groups.
*|INTERESTED:Role:Student,Staff|* Thanks for letting us know that you're a student or staff member! *|ELSE:|* We aren't sure your role at Hathaway University. Would you like to update your profile? *|END:INTERESTED|*
Multiple groups can be nested to show unique content to each group and the default to anyone else. Keep in mind that some subscribers may be a member of more than one group, and may see more than one of your conditional content blocks.
*|INTERESTED:Role:Student,Faculty|* *|INTERESTED:Role:Student|* You're a student. *|END:INTERESTED|* *|INTERESTED:Role:Faculty|* You're a faculty member. *|END:INTERESTED|* *|ELSE:|* Your role is unknown. *|END:INTERESTED|*
For the *|INTERESTED|* merge tag to work as expected, the group category can't contain any colons. To learn how to manage your group settings, check out our Edit Group Category and Names article.
If you've tested your merge tags and they're not working, here are some things to look for.
My conditional merge tags aren't working.
- Tag syntax errors
If there are syntax errors in your merge tags, they might break. Conditional merge tags are case sensitive, and won’t work if there are typos, extra spaces, or missing spaces.
- Audience data mismatch
If you use groups with your conditional merge tags, the tags can break if they don’t match your group names exactly as they appear in your audience. This includes capitalization and spacing.
- Broken conditional tags
If your conditional merge tag block doesn't work as expected, check for any unclosed conditional tags. You should include an opening and closing merge tag, and content in between. All conditional tag blocks need to start with *|IF: tag to open and an *|END:IF|* tag to close.
There’s extra whitespace or line breaks in my merge tag blocks.
- Extra space in conditional tags
If you notice extra whitespace in your conditional content, remove all spaces between your conditional merge tags to resolve the issue.
- Comma errors in plain-text emails
If you see extra line breaks in the plain-text version of your email, move any commas from outside your conditional tags to the inside. Here’s an example.