Skip to main content

Overview

Conditional blocks allow your designs to have parts that are displayed to a specific type of recipient. Only those for whom some condition is met will see that part of the message. This is an efficient alternative to producing a custom design for each small group of contacts who need to be shown different content.

You can use conditional blocks in 4 places:

  • Email designs

  • Email subject lines

  • Email sender name 

  • SMS designs

Using conditional blocks in Message Builder

You can insert conditional blocks when creating emails with Message Builder. This can be done in two ways:

  • By inserting one or several text blocks including the syntax (this option is relevant if you have only text to display in the block)

  • By inserting an HTML block including the syntax (this option is preferred if you wish to set the size and ratio of an image in a block or loop)

Using conditional blocks in the HTML editor

You will find the most commonly used conditional blocks in the Functions menu in the HTML editor. You can use them directly in the code in Splio, or more probably, once you have learned how to use them, write them directly in your HTML code tool outside Marketing Automation.

Conditional blocks with operators examples

Conditional blocks consist of one or more conditions contained between {SPLIO IF} and SPLIO ENDIF} statements. The second and next conditions must be introduced by the {SPLIO ELSEIF} statement.

Conditions are always evaluated in the order they are written. As soon as a condition is found true, the content between it and the next {SPLIO . . . } statement becomes part of the current message, and all other conditions in the block are skipped.

The content between the {SPLIO ELSE} and {SPLIO ENDIF} statements is included by default when no conditions are met.

This is best illustrated in the examples below. All examples are broken into multiple lines to make them easier to read. Note, however, that you may have to write some conditional blocks in just one line, for example for email subjects.

Conditional Blocks with the = operator

Let's see conditional blocks using the "equal to" operator. You can use it to include specific content if, and only if, a field value is equal to the value in the condition.

Explanation:

  1. If the value of the $gender$ field for the current contact equals "male", write "Dear Mr." and the contact's first name, then continue after the ENDIF statement.

  2. If the $gender$ field value is "woman", write "Dear Ms." and the contact's first name, then continue after the ENDIF statement.

  3. If the $gender$ field contains anything else, only write "Dear" with the contact's first name.

Conditional Blocks with the != operator

The "not equal to" operator is the reverse of the previous one. Conditions using != are always met except when the field contains the given value.

Explanation:

  1. Splio checks the $firstname$ field for the current contact. If the field is not empty, Splio writes the contact's first name and the words "an incredible offer for you!"

  2. Otherwise, Splio writes "Dear Client, an incredible offer for you!"

Conditional Blocks using comparison operators

These operators: > (greater than), >= (greater or equal), < (less than), <= (less or equal) – are used with numbers. For example, they allow you to include different content for contacts from different ages or spending groups.

Explanation:

  1. If the value of the $kids_number$ field for the current contact is 1 or more, write an offer about products for children.

  2. Otherwise, write an offer on other products.

Conditional Blocks using LIKE and NOT LIKE

With these operators, you can check if a field contains (or does not contain) a string of characters.

This way, if you have a field containing favorite products for each contact in your database, you can test if a specific product is present in this list with LIKE (or absent from, with NOT LIKE).

Explanation:

  1. Splio checks if the $fav_products$ field value for the current contact contains the product ID 1234.

  2. If so, a specific offer on this product is displayed.

  3. Otherwise, the generic content is included in the message.

Operators summary

Operators

Description

Example

=

Equals to

 $gender$ = "man"

!=

Is not equal to

 $status$ != "inactive"

>, >=

Greater than, greater or equal

 $kids_number$ > 0

<,<=

Less than, less or equal

 $kids_number$ < 1

LIKE "%value%"

 Contains

 $cellphone$ LIKE "%+33%"

NOT LIKE "%value%" 

 Does not contain

 NOT LIKE "@"

Conditional blocks based on a Target filter

If you have segments (filters or groups) in your database that divide your customers into audiences, e.g., according to loyalty program tiers or spending characteristics, you may want to include special content addressed to contacts from each segment using the IN SEGMENT keyword.

The IN SEGMENT keyword must be followed by the numerical ID of a contacts filter or group. You cannot use sales or loyalty filters because they contain different data and so will never match. The image shows where you can find the ID in the list of filters.

The following example assumes that you have these 3 segments:

  • ID = 22 with contacts to VIP members of your loyalty program,

  • ID = 26 with regular members of this program,

  • ID = 16 with contacts who are potential members of the program (prospects)

Explanation:

  1. If the current contact is present in segment 22 (by segment ID), include VIP content, then skip to the ENDIF statement.

  2. If the current contact is present in segment 26, include regular member content, then skip to the ENDIF statement.

  3. If the current contact is present in segment 16, include content for prospects, then skip to the ENDIF statement.

  4. If you are here, it means that neither of the above conditions was met. Include a standard offer

  5. Continue producing the message after the conditional block.

Tips and best practices

These are not rules but following them will help you avoid errors or just make your designs easier to read and analyze.

  • Always separate the operators by blank space ($var1$ > $var2$, not $var1$>$var 2$)

  • You cannot add conditional blocks by going through the WYSIWYG editor in Splio. You need to do it directly in the HTML file, use the HTML code editor or Message Builder.

  • The conditional blocks always start with a {SPLIO IF} statement, and end with a {SPLIO ENDIF}.

  • It is not possible to put one conditional block within another (this is called nesting). You need to use the syntax {SPLIO IF} . . . {SPLIO ELSEIF} . . . {SPLIO ELSE} . . . {SPLIO ENDIF} instead.