conditional content if statement if condition show or hide content liquid conditions elsif else unless case when personalization logic conditional text dynamic content

How do I use conditions to show or hide content?

SecureMailMerge uses Liquid templating, so you can wrap blocks of your subject or body in {% if %} … {% endif %} tags to show or hide them based on a recipient's column values. Combine conditions with comparison operators, else/elsif branches, and the contains keyword for full control.

Contents

SecureMailMerge personalizes your emails with Liquid templating. Alongside simple tokens like {{FirstName}}, you can use conditions to show, hide, or change blocks of content based on each recipient’s data.

Conditions work in both the subject line and the email body.

Basic if / endif

Wrap the content you want to make optional between an opening {% if %} tag and a closing {% endif %} tag. The condition is checked against the value in the named column for each recipient.

{% if Country == "Germany" %}
  Versand erfolgt aus unserem Lager in Berlin.
{% endif %}

The block is only included for recipients whose Country column equals Germany. Everyone else sees nothing in its place.

String values must be wrapped in quotes ("Germany" or 'Germany'). Numbers are written without quotes.

Capitalization, spaces, and smart quotes don’t matter

Conditions are forgiving, so small differences between your template and your spreadsheet won’t stop a condition from matching:

  • Column names are case-insensitive. {% if new == "TRUE" %} matches a column headed New, NEW, or new. You don’t have to match the exact capitalization of your header.
  • Text comparisons ignore capitalization and surrounding spaces. A condition like {% if New == "TRUE" %} matches a cell containing TRUE, true, or even True. Values are compared without regard to case or to leading and trailing spaces.
  • Straight and curly quotes are treated the same. If your editor auto-converts your straight quotes ("TRUE") into curly “smart” quotes (“TRUE”), the condition still works.
{% if new == "TRUE" %}
  Welcome aboard! Here's what to do first.
{% endif %}

The example above matches whether your column is called New or new, and whether the cell says TRUE, true, or True.

Adding an else branch

Use {% else %} to provide alternative content when the condition is false.

{% if Plan == "Premium" %}
  Thanks for being a Premium customer — your priority support line is +1 555 0100.
{% else %}
  Need a hand? Reply to this email and we'll help out.
{% endif %}

Multiple branches with elsif

Chain several conditions together with {% elsif %}. The first matching branch wins.

{% if Tier == "Gold" %}
  You've unlocked our Gold benefits.
{% elsif Tier == "Silver" %}
  You're on the Silver plan.
{% else %}
  Welcome aboard!
{% endif %}

Comparison operators

You can compare column values with any of these operators:

OperatorMeaning
==equals
!=does not equal
>greater than
<less than
>=greater than or equal
<=less than or equal
{% if OrderTotal >= 100 %}
  You qualify for free shipping!
{% endif %}

Combining conditions with and / or

Use and and or to test more than one column at once.

{% if Country == "USA" and Plan == "Premium" %}
  Your US Premium perks are active.
{% endif %}

Checking whether a cell has a value

In Liquid an empty cell is still “truthy”, so {% if Notes %} is not a reliable way to check for a value. Use blank instead — it matches empty cells and cells that contain only spaces:

{% if Notes != blank %}
  A note from your account manager: {{Notes}}
{% endif %}

To do the opposite — show content only when a cell is empty — flip the comparison:

{% if PhoneNumber == blank %}
  We don't have a phone number on file. Reply to add one.
{% endif %}

Column names with spaces

If your column header contains spaces (or other special characters), reference it with bracket notation, the same way you would in a normal token:

{% if ["Account Status"] == "Active" %}
  Your account is in good standing.
{% endif %}

For plain merge tokens (outside a condition), you can now also write a header that contains spaces directly, without the brackets: {{ First Name }} works the same as {{ ["First Name"] }}.

Matching part of a value with contains

contains checks whether a text value includes a substring.

{% if Email contains "@gmail.com" %}
  Tip: add us to your Gmail contacts so we don't land in Promotions.
{% endif %}

Inverting a condition with unless

{% unless %} is the opposite of {% if %} — the block shows only when the condition is false.

{% unless Country == "USA" %}
  International shipping rates apply.
{% endunless %}

Picking one of many values with case / when

When you need to switch between several fixed values, {% case %} is cleaner than a long elsif chain.

{% case Language %}
  {% when "de" %}
    Vielen Dank für Ihre Bestellung!
  {% when "fr" %}
    Merci pour votre commande !
  {% else %}
    Thank you for your order!
{% endcase %}

Tips

  • Conditions can wrap any content — text, links, images, or even other tokens.
  • Whitespace and line breaks inside {% if %} blocks are kept, so place your tags carefully to avoid blank lines in the final email.
  • You can combine conditions with the default value filter for fallback text, and with date formatting for dates.
  • Always close every tag: {% if %} needs {% endif %}, {% unless %} needs {% endunless %}, and {% case %} needs {% endcase %}. A missing closing tag causes a liquid syntax error.

Ready to try it yourself?

SecureMailMerge for Outlook

Runs inside Outlook — no external app needed. Free to install.

Windows Mac Web New Outlook
Try Free in Outlook

Free · No credit card required