MenuClose

Merge tags and conditions in emails

Emails and documents that use square brackets can fill in your customer's details and show or hide text depending on them. You type the instructions as ordinary text in the editor, inside [square brackets].

Merge tags: putting a value in

Write the name of a value in square brackets and it is replaced by the customer's own value when the email is sent.

Hi [firstname],

becomes

Hi Sam,
  • Capital letters do not matter: [FirstName] and [firstname] are the same.
  • Only the names available for that email are filled in. Any other text in square brackets, such as a name that is not on the list or [1], is left exactly as you typed it. Check that you have spelled the name the way the list shows it.
  • If the customer has no value for a name, it is replaced with nothing (or with your fallback, below).

A fallback for a blank value

Add a bar | and the words to use when the value is empty:

Hi [firstname|there],
The customer's first name isThe email says
Sam Hi Sam,
(blank) Hi there,

Showing text only sometimes: if, else

Put the text between [if ...] and [/if]. It is shown only when the condition is true.

[if paid]Thank you for your payment.[/if]

Add [else] for the text to show when the condition is not true:

[if mlist_optin=1]You are subscribed to our newsletter.[else]You are not subscribed to our newsletter.[/if]

[else] is optional. You can also write [endif] instead of [/if].

To show a tick or a cross:

[if mlist_optin=1]✓[else]✗[/if]

All the conditions

WriteTrue when
[if paid] the value is filled in and is not 0
[if not phone] the value is blank or 0
[if status=shipped] the value equals the word (capital letters ignored)
[if status!=shipped] the value does not equal the word
[if total>100] the value is a number greater than 100
[if total<100] the value is a number less than 100
[if total>=100] greater than or equal to 100
[if total<=100] less than or equal to 100
[if note contains parcel] the value has that word or phrase somewhere in it
[if not note contains parcel] the opposite of any of the above: put not first
  • You do not need quotes around the word, but you may use them, which helps for a phrase with spaces: [if note contains "front door"].
  • Numbers are compared as numbers, so 1,250.50 is greater than 1000. > and < only work on numbers; if either side is not a number the condition is false.
  • = and != compare as numbers if both sides are numbers, otherwise as words.
  • A name that is not on the available list counts as blank.

Blocks inside blocks

An [if] can contain another [if], up to 10 deep. Each one needs its own [/if].

[if paid]
  Thank you for your payment.
  [if total>500]As a thank you, your next delivery is free.[/if]
[else]
  Please pay by the due date.
[/if]

There is no [else if]: put another [if] inside the [else]. There is also no and or or: nest two blocks to mean "and", or use two separate blocks.

Examples

Greeting with a fallback and a note for unpaid orders

Hi [firstname|there],

[if paid]Your payment has been received.[else]Your order is waiting for payment.[/if]

Ask for missing details

[if not phone]Please reply with a phone number so the courier can reach you.[/if]

Different wording for a delivery note

[if note contains "front door"]We will leave your parcel at the front door.[/if]

Tips for the editor

  • Type the instructions as plain text. You can put [if paid] and [/if] on their own lines or inside a sentence.
  • If you put an instruction alone in its own paragraph, that paragraph is removed along with the instruction, so no blank gaps are left in the email.
  • Do not worry about extra spaces, capital letters, or bold or coloured text inside the brackets: they are ignored. Curly quotes added by the editor work too.
  • Send yourself a test email, using a customer who has the value and one who does not, before using a new email.

Mistakes and what they mean

When a template is checked, each mistake is reported with the line it is on:

MessageWhat to do
[if] is never closed with [/if] Add [/if] where the conditional text ends. Until you do, everything after the [if] is part of it.
[/if] has no [if] before it Remove the extra [/if], or add the missing [if].
[else] has no [if] before it Put [else] between an [if] and its [/if], or remove it.
a second [else] in the same [if] An [if] has one [else] only. For another case, put a new [if] inside the [else].
[if] has no condition Write what to test: [if paid].
cannot read the condition Use one of the forms in All the conditions. Names have letters, numbers, dots, dashes and underscores only, and there is no and/or.
[else if] is not supported Put an [if] inside the [else].
[if] blocks are nested more than 10 deep Simplify the email. It is sent unchanged, with the instructions showing, until you do.

Fix every message before using the email with customers: an email with mistakes can send text meant to be hidden.

What it does not do

  • It cannot use values that are not on the available list for that email. This keeps other customers' and the shop's private details out of emails.
  • It does not calculate, repeat lines or run code.
  • A customer's own words are always shown as they typed them. If a customer's name is [if x], that is what the email shows; it is never treated as an instruction.

Index Previous