Personalised content blocks in campaigns and workflows

Personalised content blocks in campaigns and workflows

Show or hide parts of an email based on what you know about each contact.

1. What this lets you do

Normally every recipient of a campaign gets the same email. Merge tags like [CUSTOMER_FIRST_NAME] change a word. Personalised content blocks change a whole section.

One campaign can show a loyalty offer to your best customers and a welcome offer to everyone else, decided separately for each person as the email is sent.

Example. A single email where members see their rewards balance and non-members see a “join us” banner, without building and scheduling two campaigns.

Behind the scenes this uses Jinja (specifically Jinjava), a widely used templating syntax. You only need the four instructions in this article.

2. Before you start

You need at least one custom attribute on your contacts. Custom attributes are the extra fields you define yourself, such as membershipTier, totalOrders or isSubscriber.

If you have not set these up yet, our step-by-step guide covers creating custom attributes and adding values to your contacts:

Tip. Pick the data type carefully when you create the attribute. It decides what comparisons you can make later (see section 5).

3. Adding a block in the editor

Personalised blocks are written in HTML, so they are added by inserting your own code rather than by dragging a block onto the canvas.

Open your campaign and insert your own code or template. Our step-by-step guide covers that:

Then wrap the content you want to show or hide, like this:

<!--{% if isSubscriber %}-->
<h2>Thanks for being a member!</h2>
<!--{% else %}-->
<h2>Join our rewards programme</h2>
<!--{% endif %}-->

Save, and send yourself a test to check the layout still looks right.

Important: the <!-- and --> are required. Every instruction must sit inside an HTML comment exactly as shown. Without them the block will not work, and you will not see an error.

4. The four instructions

InstructionWhat it does
{% if ... %}Starts a block. Shows what follows when the condition is true.
{% elif ... %}Optional. Checks another condition if the previous one was false. You can use several.
{% else %}Optional. Shown when none of the conditions above were true.
{% endif %}Ends the block. Always required.

A longer example with several options:

<!--{% if tier == 'Gold' %}-->
<p>Your Gold benefits</p>
<!--{% elif tier == 'Silver' %}-->
<p>Your Silver benefits</p>
<!--{% else %}-->
<p>Upgrade and save</p>
<!--{% endif %}-->

Blocks can also be placed inside one another, and you can use as many blocks as you like in one email.

5. Data types and what you can do with them

Every custom attribute has a data type, chosen when you create it. The type decides which comparisons are available.

TypeUse it forWhat you can check
STRINGText, such as names, tiers, citiesHas a value, equals, not equals, contains
INTEGERWhole numbers, such as order count, pointsHas a value, equals, greater / less than
DECIMALNumbers with decimals, such as spend, ratingsHas a value, equals, greater / less than
BOOLEANYes / no, such as subscriber, VIPIs true, is not true
DATEDates, such as signup date, renewalHas a value, equals, before / after another date, before / after today
ARRAYLists, such as interests, tagsHas any items, contains a given item, list every item
Writing a date. Always write dates in your conditions as 'yyyy-MM-dd', for example '2026-01-31', with the leading zeros. You can also compare against today, which always means the day the email is sent.

6. Comparisons you can use

Write thisMeansExample
attributeHas a usable value{% if tier %}
not attributeIs empty, missing or false{% if not tier %}
==Equals{% if tier == 'Gold' %}
!=Does not equal{% if tier != 'Gold' %}
> >= < <=Number comparisons{% if totalOrders > 3 %}
inIs contained in{% if 'VIP' in tags %}
> < on datesBefore / after a date{% if optInDate > '2026-01-01' %}
todayThe day the email is sent{% if renewalDate > today %}
and / orCombine two conditions{% if isVip and totalOrders > 5 %}
( )Group conditions{% if (isVip or isStaff) and active %}

Text values go in single quotes. Numbers do not.

Worked examples

<!-- Customers who have ordered more than three times -->
<!--{% if totalOrders > 3 %}--> ... <!--{% endif %}-->

<!-- Anyone who has spent over 500 -->
<!--{% if lifetimeSpend > 500 %}--> ... <!--{% endif %}-->

<!-- Contacts interested in running -->
<!--{% if 'running' in interests %}--> ... <!--{% endif %}-->

<!-- VIPs who have actually bought something -->
<!--{% if isVip and totalOrders > 0 %}--> ... <!--{% endif %}-->

<!-- Contacts with no tier set yet -->
<!--{% if not tier %}--> ... <!--{% endif %}-->

<!-- Anyone who opted in during 2026 or later -->
<!--{% if optInDate >= '2026-01-01' %}--> ... <!--{% endif %}-->

<!-- Renewals still in the future -->
<!--{% if renewalDate > today %}--> ... <!--{% endif %}-->

7. Listing every item in a list

For a list attribute you can print one line per item, instead of testing for a single one. Wrap the repeating part in {% for %} and {% endfor %}, and put the item where you want it using two curly braces.

<ul>
<!--{% for category in favoriteCategories %}-->
<li>{{ category }}</li>
<!--{% endfor %}-->
</ul>

A contact whose list is Running, Cycling sees two bullets. A contact with an empty list sees none.

The word after for is a name you choose for “one item”. Use the same name inside the curly braces. The word after in must be your list attribute.

Pair it with a condition so contacts with nothing in their list still see something:

<!--{% if favoriteCategories %}-->
<ul>
<!--{% for category in favoriteCategories %}-->
<li>{{ category }}</li>
<!--{% endfor %}-->
</ul>
<!--{% else %}-->
<p>Browse our full range.</p>
<!--{% endif %}-->
Two braces, not brackets. Inside a loop the item is written {{ category }} with curly braces. Square brackets such as [category] are merge tags for contact fields and will not work here.

8. What happens to missing values

You do not need to worry about contacts with gaps in their data.

  • An attribute with no value counts as false, so the contact falls to your {% else %}.
  • An attribute name that does not exist also counts as false. Nothing breaks.
  • A number set to 0 counts as false. Use {% if totalOrders > 0 %} if you mean “has ordered at least once”.
  • An empty list counts as false.
Always include an {% else %}. It is what contacts with missing data will see, and it keeps your email from having an empty gap.

9. Testing your email

A test send always shows the same version. Test sends and previews do not use real contact data, so every block will fall to the same branch. This is expected and does not mean your block is broken.

To check your conditions properly:

  1. Create a small segment containing two or three real contacts with different attribute values.
  2. Send the campaign to that segment.
  3. Confirm each contact received the version you expected.

Use contacts whose values sit either side of your condition. For {% if totalOrders > 3 %}, use one contact with 1 order and one with 10.

10. If something is not working

What you seeMost likely cause
The instruction text appears in the delivered emailThe <!-- and --> are missing. Every instruction must be inside an HTML comment.
Everyone gets the same versionYou are looking at a test send. Send to a real segment instead.
A section is missing entirelyAn {% endif %} is missing, or the condition uses an attribute name that does not exist.
The condition is always falseThe attribute has no value on those contacts, or a number is being compared with quotes around it. Write > 3, not > '3'.
A list prints nothingThe attribute is not set up as a list, or the contact’s list is empty. Check the attribute type on the contact record.
The list item name appears as textThe item is written with square brackets. Inside a loop use {{ item }} with curly braces.
The layout breaksThe block starts inside one table cell and ends in another. Wrap whole rows or whole sections.

11. Good to know

  • Attribute names are not case sensitive: totalOrders and totalorders both work.
  • Only if, elif, else and endif are supported. Loops and other Jinja features are not.
  • Use merge tags such as [CUSTOMER_FIRST_NAME] to print a value. The {% ... %} instructions decide what to show, not what to print.
  • Links inside a hidden section are never sent, but may still appear in your link reports.
  • Write dates as 'yyyy-MM-dd' with leading zeros. '2026-1-5' will not compare correctly.
  • renewalDate > today is false on the day itself. Use >= if you mean “today or later”.
  • Decimal attributes cannot be set by CSV import. Set them on the contact record directly.
Need a hand? Contact tinyEmail Support with your campaign name and the block you are trying to set up, and we will check it with you.