• Features
  • Services
    • Email Authentication
    • Agency Partnerships
    • Email Training
    • Inbox Brand Visibility
    • Deliverability
  • Resources
    • Knowledge Base
    • API documentation
    • Blog
    • Status
    • BIMI inspector
  • About us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    • Privacy recommendations
  • Features
  • Services
    • Email Authentication
    • Agency Partnerships
    • Email Training
    • Inbox Brand Visibility
    • Deliverability
  • Resources
    • Knowledge Base
    • API documentation
    • Blog
    • Status
    • BIMI inspector
  • About us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    • Privacy recommendations
  • Login
    EN CS
Mailkit logo
  • Features
  • Services
    • Email Authentication
    • Agency Partnerships
    • Email Training
    • Inbox Brand Visibility
    • Deliverability
  • Resources
    • Knowledge Base
    • API documentation
    • Blog
    • Status
    • BIMI inspector
  • About us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    • Privacy recommendations
  • Features
  • Services
    • Email Authentication
    • Agency Partnerships
    • Email Training
    • Inbox Brand Visibility
    • Deliverability
  • Resources
    • Knowledge Base
    • API documentation
    • Blog
    • Status
    • BIMI inspector
  • About us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    • Privacy recommendations
  • Login
    EN CS
EN CS
Login
  • Mailkit
  • Resources
  • Knowledge Base
  • Using templates
  • Conditions & operators
  • Campaigns (16)
    Campaign management Email campaigns Remarketing campaigns Transactional Campaigns Confirmation campaigns SMS Campaigns Content and personalisation Campaign testing and previews Adding links Advanced tracking Content merge tags Campaign AB testing Delivery capping Campaign delivery settings File Manager Manage Polls
  • Journeys (3)
    Journey management Journeys editor Nodes
  • Mailing lists (6)
    Manage recipient list Manual recipient import Subscribe form generator Engagement score Recipient filtering Unsubscribes
  • Reports (6)
    Summary Reports Campaign Reports Campaign delivery report Event Reports Recipients report Deliverability Report
  • Using templates (10)
    Email Templates Conditions & operators Including and processing Working with data Using date & time functions User interface templates Micro-site templates Content Styles Plug-ins Filters and functions
  • Account management (8)
    My account Two-factor authentication (2FA) Data sources Integration Tags and Topics SPF records DMARC record Mailkit Cookies
  • Visual builder (6)
    How Visual builder works Content Blocks Modules Smart Elements Conditional blocks Ready-made templates
  • Campaigns
  • Journeys
  • Mailing lists
  • Reports
  • Using templates
  • Account management
  • Visual builder
Campaign management Email campaigns Remarketing campaigns Transactional Campaigns Confirmation campaigns SMS Campaigns Content and personalisation Campaign testing and previews Adding links Advanced tracking Content merge tags Campaign AB testing Delivery capping Campaign delivery settings File Manager Manage Polls
Journey management Journeys editor Nodes
Manage recipient list Manual recipient import Subscribe form generator Engagement score Recipient filtering Unsubscribes
Summary Reports Campaign Reports Campaign delivery report Event Reports Recipients report Deliverability Report
Email Templates Conditions & operators Including and processing Working with data Using date & time functions User interface templates Micro-site templates Content Styles Plug-ins Filters and functions
My account Two-factor authentication (2FA) Data sources Integration Tags and Topics SPF records DMARC record Mailkit Cookies
How Visual builder works Content Blocks Modules Smart Elements Conditional blocks Ready-made templates
Search

Conditions & operators

You can use the IF/ELSIF/ELSE logical conditions wherever you want to apply any personalization or ensure that the automated email is up-to-date.

The following examples will show you some of the most common use-cases of conditions. Let's begin with some basic theory.

Creating a condition

IF / ELSIF / ELSE conditions are used to define "what if" - if condition is met, or not.

[% IF "condition" -%]content or further templating logic to be processed/returned if condition IS met
[% ELSE -%]content/commands to be processed if condition IS NOT met[% END -%]

Each condition starts with: [% IF "something" ...is equal to, contains, is not equal to ... "something" -%] and ends with: [% END -%]. In creating the condition, you can use content merge tags, content from data sources, as well as custom variables and structures passed through the API.

Supported operators:

== ... equal
!= ... not equal
< ... less than
<= ... less or equal
> ... greater than
>= ... greater or equal

! ... empty
variable.match('string') ... contains string (supports regular expressions)

&& ... AND operator
|| ... OR operator

Personalized salutation

Objective of the condition:

If the gender of the recipient is male – display "Dear Sir",
If the gender of the recipient is female – display "Dear Madam",
If no gender is specified – display "Dear customer",
If the gender is stated and at the same time the name is given – display last name in the salutation.

Condition used:

[% IF recipient.GENDER == 'M' -%]Dear Sir
[% ELSIF recipient.GENDER == 'F' -%]Dear Madam
[% ELSE -%]Dear customer[% END %]
[% IF recipient.GENDER !='' && recipient.LAST_NAME !='' -%][LAST_NAME],[% ELSE -%],[% END -%]

Message in recipient's language

Objective of the condition:

The recipient record has a language code stored in the field CUSTOM25. This language should be used for communication with the recipient. The values are "de" for german, "es" for spanish. English (default language) will be used for all others.

Condition no.1 used:

[% IF recipient.CUSTOM25 == 'de' -%]Interessieren Sie sich nicht für unseren Newsletter? Klicken Sie hier, um sich abzumelden
[% ELSIF recipient.CUSTOM25 == 'es' -%]No te interesa nuestro boletín? Haga clic para cancelar la suscripción.
[% ELSE -%]Not interrested in our newsletter? Click to unsubscribe [% END -%]

Condition no.2 used:

Condition used in the template to use different content areas in the body of an email depending on recipient's language.

[% IF recipient.CUSTOM25 == 'de' -%][CONTENT2]
[% ELSIF recipient.CUSTOM25 == 'es' -%][CONTENT3]
[% ELSE -%][CONTENT][% END -%]

Different content

Objective of the condition no.1:

Use different text color based on recipient gender.

Condition used:

<span class="color:#[% IF recipient.GENDER == 'F' -%]c40a80[% ELSE -%]0a59c4[% END -%]">Thank you!</span>

Objective of the condition no.2:

Recipient with "yes" in CUSTOM1 and "666" in CUSTOM2 fields will receive different content than the rest of recipients.

Condition used:

[% IF recipient.CUSTOM1 == 'yes' && recipient.CUSTOM2 == '666' -%]
Congratulations! You are a winner!
[% ELSE %]
We are sorry, better luck next time!
[% END -%]

Objective of the condition no.3:

Show a specific content to all recipients with mailbox on domains seznam.cz, email.cz, post.cz, spoluzaci.cz, stream.cz, or firmy.cz. Other recipients will not see anything.

Condition used:

[% email = recipient.EMAIL -%]
[% IF email.match('seznam.cz') || email.match('email.cz') || email.match('post.cz') || email.match('spoluzaci.cz') ||
email.match('stream.cz') || email.match('firmy.cz') -%]Find out how not to miss your news and discounts![% END -%]

Where can you use it?

And where to insert the condition? You can insert the condition into the content style editor or work with it in HTML code as with plain text. However, the conditions are managed by the template language and thus primarily belong to the templates. In the case of use directly in the editor, it is necessary to think about a valid notation in the HTML code.

In case you need help with creating your condition, don't hesitate to contact us, we will be happy to help.

Contact us

Let us know what your campaign objectives are and we'll create a plan that works for you.

+420 277 001 800
sales@mailkit.com


Processing of information provided using this form is governed by our Privacy Policy.

Required
Required
Required
Mailkit logo

A Czech emailing platform with its own infrastructure, that is a leader in international mailing distribution.

 

  • Features
  • Services
  • Resources
  • About us

services

  • Email Authentication
  • Agency Partnerships
  • Email Training
  • Inbox Brand Visibility
  • Deliverability

ReSOURCES

  • Knowledge Base
  • API documentation
  • Blog
  • Status
  • BIMI inspector
Logo Maawg
Logo Experience
Logo CSA
Logo Signal spam
Logo ISO-27001
Logo ISO-9001
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
© 2006-2022 Mailkit - All rights reserved