Placeholders with Alternative Content

Prev Next

Overview

This placeholder inserts one of two text or image variants into a message, depending on whether a recipient meets a condition. During sendout, Mapp Engage checks the recipient's data and inserts the matching variant.

You enter this placeholder as code. The graphical Personalization Builder does not support it. For more than two variants, use a personalization rule with InsertIf and InsertElse blocks. See Personalization Rules Syntax.


Background Information

The placeholder needs three pieces of information:

  • The condition that the recipient's data must meet

  • The text or image to insert if the condition is met

  • The text or image to insert if the condition is not met

Conditions use the JSP Expression Language. You can also use Mapp Engage functions.


Configuration and Behavior

Use this structure:

<%${(condition) ? 'variant if true' : 'variant if false'}%>

Rules inside the expression:

  • The expression is wrapped in ${ ... }.

  • Fixed text values are written in single quotes, for example 'Welcome back'.

  • Attribute references are written without surrounding quotes, for example message['Name'].

  • To check whether an attribute has a value, use not empty. To check whether it is missing, use empty.

Example

The header shows the saved message name. If no message name exists, it shows the subject instead.

<%${(not empty message['Name']) ? message['Name'] : message['Subject']}%>

Result:

  • If message['Name'] has a value, that value is inserted.

  • If message['Name'] is empty, message['Subject'] is inserted instead.