Set up dynamic content with if-structures

If-structures are a text-based way to add dynamic content to your messages. They let you show different text, images, or links to different contacts in the same email, based on the information you have about them in your custom fields.

Use if-structures when the structure-level dynamic content panel is not specific enough — for example, when you want to personalise a single sentence inside a paragraph, or swap out just a few words of a greeting. If-structures work in the Email builder, the Wizard template, and the HTML editor.


Prerequisites

  • You know the placeholder name of the custom field you want to use. You can find placeholder names in Settings > Manage custom fields.
  • Your test profile in Settings is filled in with representative values, so you can preview the output.

Attention if-structures only work with custom fields. If you need to show content based on a segment, use the structure-level dynamic content panel of the Email builder instead.


Basic syntax

An if-structure is built from three parts: an opening {if ...}  , an optional {else}  , and a closing {/if}  . Between them, you put the content you want to show.

Show content only when the condition is true:

{if ::firstname::!=""}

Show one piece of content when the condition is true, and a fallback when it is not:

{if ::firstname::!=""}Hello #firstname#,{else}Hello there,{/if}

The part between {if   and }   is the condition — this is where you describe what you want to check. Everything else is just content

Referring to a custom field

Inside an if-structure, you refer to a custom field by wrapping its placeholder in double colons: ::placeholder::  . For example, to check the first name field, you write ::firstname::  .

This is different from the #placeholder# syntax used for regular personalisation. Inside if-structures, always use the ::placeholder:: form.


Available functions

Check the value of a contact field

The most common use of an if-structure is to check what is stored in a contact field and show content accordingly.

{if ::language::=="fr"}Bonjour{else}Hello{/if} 

Contacts whose contact language is French see "Bonjour". Everyone else sees "Hello".


Uppercase, lowercase, uppercaseFirst

Value checks are case-sensitive with if-structures. "Value" and "value" are not the same, so some contacts may fall outside your condition simply because their field was stored with different capitalisation. Wrap the field in uppercase(...)  or lowercase(...)  to compare safely:

{if uppercase(::placeholder::)=="VALUE"}...{/if} 

{if lowercase(::placeholder::)=="value"}...{/if} 

Support tip Use {uppercaseFirst(::placeholder::)}  in your content when you want to display a field with only the first letter capitalised — handy for greetings where you want "Hello Sarah" regardless of how the name was originally stored.

Fallback

Use {fallback(...)}  when you want to show a contact's field value, with a default for contacts where }the field is empty. It is simpler than a full if-else structure for this common case.

Dear {fallback(::firstname::,"customer")}

Contacts with a first name see "Dear Sarah". Contacts without one see "Dear customer". Note that {fallback(...)}  is used on its own inside curly brackets — it does not need surrounding {if}  tags.


Contains

Use contains()  when you only want to check part of a field value, not an exact match.

{if contains(::haystack::,"Needle")} … {else} … {/if}

Length

Use length(...)  when the number of characters in a field should drive the content. For example, imagine you sell personalised keychains, but only up to 7 characters fit on the product:

{if length(::firstname::)<7} Article about personalised keychains {else} … {/if}

Where to place if-structures

You can place if-structures anywhere you can type text: inside a text element in the Email builder, in the text areas of the Wizard template, or in the HTML editor. They work the same in all three tools.


Nesting

You can put if-structures inside each other for more specific combinations:

{if ::language::=="NL"}
    {if ::country::=="BE"}Welkom in België
    {else}Welkom{/if} 
{else}Welcome{/if}

Keep nesting to a minimum. Two levels deep is usually plenty — more than that becomes hard to read and easy to break.

Attention Fill your test profile in Settings with representative values to preview if the output looks right.


Common mistakes to avoid

  • Forgetting to close the if-structure with {/if} . An unclosed structure breaks the message and can produce unexpected output.
  • Using #placeholder#  instead of ::placeholder:: . Inside an if-structure, only the ::placeholder::  form works.
  • Using a placeholder name that does not match what is in Settings. Placeholder names must match exactly. Check Settings > Manage custom fields if you are not sure.
  • Comparing values with different capitalisation. "FR"  and "fr"  are not equal. Wrap the field in uppercase(...)  or lowercase(...)  to make the comparison case-insensitive.
  • Trying to check an interest or segment. If-structures only work with custom fields. For interests or segments, use the structure-level dynamic content panel in the Email builder.

Next steps

Did this answer your question? Thanks for your feedback There was a problem submitting your feedback. Please try again later.

Didn't find what you were looking for? Contact Us Contact Us