- 2 Minutes to read
- Print
- DarkLight
Alternative Content - Personalization Placeholder
- 2 Minutes to read
- Print
- DarkLight
Goal
To include one of two text or image variants in a message, depending on whether or not the recipient fulfills a defined condition, using personalization placeholders.
This kind of personalization can only be built in text mode. The graphical personalization Builder does not support this kind of personalization.
It is also possible to create this personalization (and far more complex personalizations!) using personalization Rules - InsertIf/InsertElse.
Necessary Information
To program two alternatives into a message, Mapp Engage needs 3 pieces of information:
Which attribute should fulfill which condition?
What happens if the condition is met?
What happens if the condition is not met?
During sendout, Mapp Engage checks whether each recipient's attribute data fulfills the specified condition. If so, a particular text/image is inserted. If not, a different text/image is inserted.
Structure of the personalization placeholder
The personalization placeholder is formulated as follows:
<%${(attribute and condition)? 'text/picture1' : 'text/picture2'}%>
The personalization placeholder is, as always, defined by <% and %> (see personalization Placeholders).
Expression:
To set up conditions and to enter variants, the following expression is used: ${. . . }
Within the expression:
Text is set in single quotes (').
If an attribute is used, the attribute name is inserted without single quotes.
The user['Title'] attribute is an exception; in this case, the queried value (1, 2, -1) is written in single quotes.
The three types of information above are now defined within the expression, as follows:
Which attribute should satisfy which condition?
The first part of the expression indicates which attribute should be queried.
(Attribute and condition): In the first brackets before the question mark, the attribute to be queried and its value are entered.
It is also possible to query whether an attribute has a value for the recipient (not empty) or is empty (empty).JSP Expression Language is used to build the query. It is also possible to use Mapp Engage functions (see Mapp Engage Functions).
What happens if the condition is met?
The second element of the expression defines what happens when the condition is met.
? Separation character between the query and the first variation.
'Text/Picture1' : This is the text/image that is inserted when the condition is met.
What happens if the condition is not met?
Colon (:): Separation character between the first variation and the second variation
'Text/Picture2' :This is the text/image that is inserted when the condition is not met.
Example
If the message has a saved name, the name of the message should be shown in the message header field.
If no name was saved for the message, the text of the subject line should be shown in the message.
The personalization placeholder looks like this:
<%${(not empty message['Name'])? message['Name']: message['Subject']}%>
(not empty message['Name']) : Queries whether a name has been entered for the message.
message['Name'] : This text is displayed if the query is true and a message name exists. In this case, the value that was stored as the message name is displayed.
message['Subject'] : This second text is displayed if the query is not true, i.e. when no value is available in message['Name'], the value stored in message['Subject'] is inserted.