---
title: "Personalization with Related Data"
slug: "personalization-with-related-data"
updated: 2025-02-06T14:39:09Z
published: 2025-02-06T14:39:09Z
canonical: "docs.mapp.com/personalization-with-related-data"
---

> ## 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.

# Personalization with Related Data

## **Overview**

Using related data allows you to personalize messages dynamically based on stored data sets. This enhances engagement by tailoring content to recipients' behavior, preferences, or historical interactions.

## **How Personalization with Related Data Works**

- **Placeholders**: Insert individual data into a message using placeholders.
- **Personalization Rules (InsertIf & InsertElse)**: Define conditions for when specific content is displayed.
- **Boolean Expressions**: Evaluate conditions using logical operations (e.g., the contact has made a purchase, is within a specific segment, etc.).
- **Dynamic Content**: Change email content based on recipient-specific data stored in related data sets.

## **Constructing Personalization Rules**

### **Basic Personalization Rule**

```plaintext
<%InsertIf expression="${function}"%>Personalized Content<%/InsertIf%>
```

- The **InsertIf** tag defines when content should be displayed.
- The **expression** attribute holds the condition.
- The **InsertElse** tag allows for fallback content.

### **Example 1: Targeting Customers Who Purchased Shoes**

```plaintext
<%InsertIf expression="${ecm:countMapElements(ecx:filter(user.RelatedAttribute['Purchases']['ArticleType'], 'Shoes'))}"%>
Special offer on shoe accessories!
<%/InsertIf%>
```

### **Example 2: Targeting Customers Who Purchased in the Last Month**

```plaintext
<%InsertIf expression="${ecm:countMapElements(ecx:filter(user.RelatedAttribute['Purchases']['Date'], ecm:formatDate(ecm:subtractInterval(date['Today'], 'P1M'))))}"%>
Exclusive deal for recent buyers!
<%/InsertIf%>
```

### **Example 3: Default Offer for All Other Contacts**

```plaintext
<%InsertElse%>Check out our latest deals!<%/InsertElse%>
```

## **Best Practices**

✔ Use **InsertIf** and **InsertElse** to create dynamic experiences.

✔ Keep conditions simple to ensure efficient rendering.

✔ Store reusable personalization rules in the **code view** for consistency.

✔ Test conditions in a staging environment before deploying to production.

## Related

- [Use Related Data in a Message](/use-related-data-in-a-message.md)
