--- title: "Code View for Personalization Rules" slug: "code-view" description: "Create personalization rules as code in the Mapp Engage Personalization Builder: when to use Code View, its limitations, and two code examples." status: "update" updated: 2026-11-04T10:36:13Z published: 2026-11-04T10:36:13Z canonical: "docs.mapp.com/code-view" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.mapp.com/llms.txt > Use this file to discover all available pages before exploring further. # Code View for Personalization Rules ## Overview Code View in the Personalization Builder lets you create personalization rules directly as code. It is intended for users who have at least basic knowledge of the expression language and some experience with queries. --- ## Navigation Path 1. Navigate to *Audience > Segmentation > Personalization*. 2. Create or edit a personalization. 3. Click **Code**. --- ## Key Behaviors and Limitations - **Code-only rules**: Some rules can only be created in code, for example conditions with advanced functions or special attribute types. See [Functions](/v1/docs/mapp-engage-functions). - **Default structure**: When you create a new personalization, the editor automatically creates a first `InsertIf` block without content. - **Validation**: Use **Preview** to check the rule before you save or reuse it. See [Personalization Builder: Preview](/v1/docs/preview-personalization). - **Reuse**: You can save personalizations created in code and reuse them in other messages. - **Switching back to the graphical interface**: This is only possible if the code matches the structure that the graphical interface creates. Rules with code-only elements stay in Code View. For the syntax of conditions and blocks, see [Personalization Rules Syntax](/v1/docs/syntax-of-personalization-rules). --- ## Examples ### Inline placeholder This example inserts the contact's first name into a sentence. You can place the placeholder anywhere in plain text or HTML. ```plaintext Thanks for your order, <%${user['FirstName']}%>! ``` ### Greeting with fallback This example adapts the greeting to the contact's title and last name. If the title or the last name is missing, a general greeting is used. ```plaintext <%InsertIf expression="${(user['Title'] == '1') && (not empty user['LastName'])}" id="Greeting_M"%>Hello Mr. <%${user['LastName']}%>,<%/InsertIf%> <%InsertElse expression="${(user['Title'] == '2') && (not empty user['LastName'])}" id="Greeting_F"%>Hello Ms. <%${user['LastName']}%>,<%/InsertElse%> <%InsertElse id="Greeting_Default"%>Hello,<%/InsertElse%> ``` For more examples, see [Personalization Rule Examples](/v1/docs/personalization-builder-examples).