---
title: Loyalty and rewards
slug: data-platform/docs/usecase-loyalty-and-rewards
docTags: 
createdAt: 2026-08-10T12:05:16.000Z
---

Concluding the ecommerce use case, your website has a loyalty and rewards system that you want to track through Optimizely Data Platform (ODP). To do so, you need to create custom events, objects, fields, and relationships.

## Events

To learn about events, see [events](docId\:w0DeSMy7YSyAm7PnwzGqq).

### Event Type: `loyalty`

| Event Action                | Fields                                                                                                         |
| --------------------------- | -------------------------------------------------------------------------------------------------------------- |
| \`points\_added\`           | \`previous\_loyalty\_points\_balance\`\ \`current\_loyalty\_points\_balance\`\ \`loyalty\_change\_in\_points\` |
| \`points\_added\`           | \`previous\_loyalty\_points\_balance\`\ \`current\_loyalty\_points\_balance\`\ \`loyalty\_change\_in\_points\` |
| \`referral\_completed\`     | \`loyalty\_referral\_code\_id\`\ \`loyalty\_referred\_customer\_email\`                                        |
| \`referral\_link\_shared\`  | \`loyalty\_referral\_code\_id\`\ \`loyalty\_referred\_customer\_email\`                                        |
| \`tier\_earned\`            | \`previous\_loyalty\_tier\_id\`\ \`current\_loyalty\_tier\_id\`                                                |
| \`tier\_lost\`              | \`previous\_loyalty\_tier\_id\`\ \`current\_loyalty\_tier\_id\`                                                |
| \`yotpo\_coupon\_awarded\`  | \`yotpo\_redemption\_id\`\ \`yotpo\_redemption\_option\_id\`\ \`yotpo\_perk\_id\`                              |
| \`yotpo\_coupon\_redeemed\` | \`yotpo\_redemption\_id\`\ \`yotpo\_redemption\_option\_id\`                                                   |
| \`yotpo\_coupon\_reminder\` | \`yotpo\_redemption\_option\_id\`\ \`yotpo\_points\_needed\`                                                   |

## Schema

To learn about creating objects, fields and relationships and then update the newly created schema, see [Objects and fields](docId\:jWr_e_ykksqkpe5ZA-7fn).

### Objects

| Object Name                                       | Description                                                                            |
| ------------------------------------------------- | -------------------------------------------------------------------------------------- |
| Loyalty Tiers (`loyalty_tiers`)                   | Stores data about available Loyalty Tiers that customers can attain via loyal actions. |
| Loyalty Referral Codes (`loyalty_referral_codes`) | Stores all available referral codes and metrics on sharing.                            |

### Fields

**Events (events)**

| Field Name                        | Type   | Description                                                          |
| --------------------------------- | ------ | -------------------------------------------------------------------- |
| `previous_loyalty_tier_id`        | string | The ID of the tier that the customer was previously associated with. |
| `current_loyalty_tier_id`         | string | The ID of the tier that the customer is now associated with.         |
| `previous_loyalty_points_balance` | number | The loyalty points balance of the customer before this event.        |
| `current_loyalty_points_balance`  | number | The loyalty points balance of the customer after this event.         |
| `loyalty_change_in_points`        | number | The total change in loyalty points due to this event.                |
| `loyalty_referral_code_id`        | string | The unique referral code that this event applies to.                 |
| `loyalty_referred_customer_email` | string | The email of the customer that was referred.                         |

**Customers (customers)**

To learn about Customers in ODP, see [Customers](docId\:kJQOKwTiRoXN6KRiV0sb9).

| Field Name                   | Type    | Description                                                                             |
| ---------------------------- | ------- | --------------------------------------------------------------------------------------- |
| `loyalty_points_balance`     | number  | The number of loyalty points that the customer currently has.                           |
| `loyalty_referral_code_id`   | string  | The unique Referral Code ID assigned to the customer.                                   |
| `loyalty_tier_id`            | string  | The ID of the Loyalty Tier that the customer is associated with.                        |
| `loyalty_profile_created_at` | ts      | The date & time that the customer record was created in the connected loyalty app.      |
| `loyalty_profile_updated_at` | ts      | The date & time that the customer record was last updated in the connected loyalty app. |
| `loyalty_is_enrolled_member` | boolean | If true, the customer is currently enrolled in your loyalty program.                    |

**Loyalty tiers (loyalty\_tiers)**

| Field Name              | Type   | Description                                                                          |
| ----------------------- | ------ | ------------------------------------------------------------------------------------ |
| `loyalty_tier_id`       | string | The unique identifier for a Loyalty Tier.                                            |
| `name`                  | string | The name of the Loyalty Tier.                                                        |
| `rank`                  | number | The numeric rank of this Loyalty tier relative to other Loyalty Tiers.               |
| `required_dollar_spend` | number | The amount of dollars required to be spent by a customer to reach this Loyalty Tier. |
| `description`           | string | A description of this Loyalty Tier.                                                  |
| `required_points`       | number | The number of points required to reach this Loyalty Tier.                            |
| `required_purchases`    | number | The number of purchases required to reach this Loyalty Tier.                         |

**Loyalty referral codes (loyalty\_referral\_codes)**

| Field Name                 | Type    | Description                                                                           |
| -------------------------- | ------- | ------------------------------------------------------------------------------------- |
| `loyalty_referral_code_id` | string  | The unique referral code assigned to a customer.                                      |
| `total_shares`             | number  | The number of times that this referral code has been shared.                          |
| `order_conversions_count`  | number  | The number of orders that have resulted from this referral code.                      |
| `order_conversions_amount` | number  | The dollar amount of the number of orders that have resulted from this referral code. |
| `expiration_ts`            | ts      | The date & time that the referral code expires, if it does.                           |
| `is_expired`               | boolean | Determines whether or not the referral code is expired.                               |
| `total_clicks`             | number  | The total number of clicks of the shared referral code URL.                           |
| `referral_url`             | string  | The unique referral code URL.                                                         |

### Relationships

| Name                    | Parent                               | Child                                             |
| ----------------------- | ------------------------------------ | ------------------------------------------------- |
| `loyalty_referral_code` | `events.loyalty_referral_code_id`    | `loyalty_referral_codes.loyalty_referral_code_id` |
| `previous_loyalty_tier` | `events.previous_loyalty_tier_id`    | `loyalty_tiers.loyalty_tier_id`                   |
| `current_loyalty_tier`  | `events.current_loyalty_tier_id`     | `loyalty_tiers.loyalty_tier_id`                   |
| `loyalty_referral_code` | `customers.loyalty_referral_code_id` | `loyalty_referral_codes.loyalty_referral_code_id` |
| `loyalty_tier`          | `customers.loyalty_tier_id`          | `loyalty_tiers.loyalty_tier_id`                   |
