Personalization Rules Syntax

Prev Next

Overview

Personalization rules control whether specific content is inserted into a message, based on conditions evaluated for each recipient. The condition is defined in the start tag of the rule and determines whether the enclosed content is shown.


Configuration and Syntax

Basic structure

  • Start and end tag: A rule starts with <%InsertIf expression="${...}"%> and ends with <%/InsertIf%>. The content between the tags is inserted if the condition is true.

  • Expression: The condition is written inside ${...} in the expression attribute. Expressions use the JSP Expression Language (EL).

  • Multiple conditions: You can combine several conditions in one expression with and and or.

  • Parentheses: The Personalization Builder encloses each condition in its own parentheses. When you combine conditions in code, use parentheses to control the order of evaluation.

Build a single condition

  1. Reference the attribute to check.

  2. Add the relation operator.

  3. Add the value to compare against.

Example: Insert text only if the recipient's country code is DE.

<%InsertIf expression="${user['ISOCountryCode'] == 'DE'}"%>text<%/InsertIf%>

To compare dates, use the date functions. See Compare Dates.

Attribute references and values

  • Wrap fixed text values in single quotes, for example 'DE'. Numbers can be written without quotes, for example user['Title'] == 1.

  • To check whether an attribute has a value, use empty or not empty, for example ${not empty user['FirstName']}.

  • If you compare one attribute to another attribute, do not use quotes around the attribute reference.

Supported relations

Relation

Description

<

Less than

>

Greater than

<=

Less than or equal

>=

Greater than or equal

==

Equal

!=

Not equal

empty

The attribute has no value

not empty

The attribute has a value

You can link single conditions with operators to create rules that check several conditions in one expression.

Operator

Description

and

Both conditions must be true.

or

At least one of the conditions must be true.

Example: Insert text only if both conditions are true.

<%InsertIf expression="${(user['ISOCountryCode'] == 'DE') and (user['Title'] == 1)}"%>text<%/InsertIf%>

Use parentheses to control logic

Use parentheses to create the required hierarchy, especially when you combine and and or.

Example: Insert content if the region is Paris and the title is 1, or if the region is Quebec and the title is 1.

<%InsertIf expression="${((user.CustomAttribute['Region'] == 'Paris') and (user['Title'] == 1)) or ((user.CustomAttribute['Region'] == 'Quebec') and (user['Title'] == 1))}"%>text<%/InsertIf%>

Add alternatives with InsertElse

To define alternative content, add InsertElse blocks after the InsertIf block. An InsertElse block can have its own condition. An InsertElse block without a condition is the default and is used if no other condition applies. Mapp Engage inserts only the content of the first block whose condition is true.

<%InsertIf expression="${user['ISOCountryCode'] == 'DE'}"%>Hallo<%/InsertIf%>
<%InsertElse expression="${user['ISOCountryCode'] == 'FR'}"%>Bonjour<%/InsertElse%>
<%InsertElse%>Hello<%/InsertElse%>

For how the blocks are evaluated, see Personalization Rules - InsertIf-InsertElse.


Mapp Engage Functions

In addition to the operators on this page, Mapp Engage provides functions, for example to compare dates, check parts of a value, use regular expressions, or format text. See Functions and Function Basics.