Personalization Builder: Code View

Prev Next

Overview

The Code view in the Personalization Builder lets you create complex personalizations directly as code. It is recommended for system users who have at least basic knowledge of expression language and some experience creating queries.


Navigation Path

Audience > Segmentation > Personalization

image2022-6-22_17-29-27.png


Key Behaviors and Limitations

  • Code-only rules: Some InsertIf / InsertElse rules can only be created in code. These advanced functions are not available in the graphical interface (see Mapp Engage Functions).

  • Reuse: You can insert existing personalizations as code and save them for reuse in Mapp Engage.

  • Creation field and validation: Create the personalization rule in the text field and use Preview to validate the rule.

  • Default structure: When you create a new personalization in the Personalization Builder, the editor automatically creates a first InsertIf block with no content.

  • Switching back to the graphical interface: You can switch from code view back to the graphical interface only if the rules you entered manually are identical to the rules that are automatically created in the graphical interface.


How InsertIf / InsertElse rules work in Code View

  1. Build your personalization logic using InsertIf blocks and add InsertElse blocks for fallback behavior.

  2. Use nested expressions when you need more complex conditions, because the graphical interface does not support complex nested expressions.

  3. Validate the result with Preview before saving or reusing the personalization.


Examples

1 Inline personalization (single word)

This example inserts a contact’s first name into a sentence. You can place the placeholder directly in the text wherever needed, which is useful in plain text or HTML.

Example

Thanks for your order, <%user['firstname']%>!

Result
The recipient’s first name is inserted into the sentence.


2 Conditional greeting with fallback

This example demonstrates a greeting that adapts based on the recipient’s gender, incorporating fallback logic. This level of personalization is only available in the Code view because the graphical interface does not support complex nested expressions. Use this method if you need full control and understand Mapp Engage’s expression language.

Example

<%InsertIf expression="${((user['Title'] == '1') && (! empty user['LastName']))}" id="Greeting_M" %>
Hello Mr. <%${user['LastName']}%><%/InsertIf%>
<%InsertElse expression="${((user['Title'] == '2') && (! empty user['LastName']))}" id="Greeting_F" %>
Hello Ms. <%${user['LastName']}%><%/InsertElse%>
<%InsertElse id="Greeting_Default" %>Hello,<%/InsertElse%>

Result

  • If the conditions match, the greeting includes the recipient’s last name.

  • If no condition matches, the default greeting is shown.