# Reward advocates with loyalty points

> You can combine referrals and loyalty programs to increase customer engagement and gain new customers.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

Let's imagine that we run an online marketplace and want to [create a campaign](/docs/product/campaigns/create-and-manage-campaigns.md#create-a-campaign-from-scratch)
to issue referral codes to any customer who buys goods with a total value equal to or greater
than $100. Once their friend redeems the referral code, the advocate will receive a loyalty
reward and the new customer will receive a discount on their purchase.

In a [standard campaign](/docs/product/campaigns/overview#standard-campaigns), let's
create:

1. A [promotion rule](/docs/product/rules/overview.md#promotion-rules) to [create a referral code](/docs/product/rules/effects/use-effects.md#create-a-referral-code)
   when the customer spends $100 or more in one session.
1. A promotion rule to award 20 loyalty points to the advocate and issue a 20% discount to
   the referred customer when the referral code is redeemed.
1. A promotion rule for our customers to be able to pay for new orders with their loyalty
   points.

:::note
Create at least one [profile-based loyalty program](/docs/product/loyalty-programs/profile-based/create-pb-programs.md),
and the [**Loyalty** and **Referrals** features](/docs/product/campaigns/settings/manage-campaign-features.md)
have to be enabled.
:::

## Create a referral code for purchases worth $100 or more

Let's [build a rule](/docs/product/rules/create-and-manage-rules.md#create-a-promotion-rule) to
create a referral code for customers who spend $100 or more at once in our online shop. Let's
also send our customers a notification with their code.

We can name the rule `Referral code creation`. It has one condition and two effects.

### Rule 1: Condition

**Check attribute value**:

- Attribute is **Session Total (Current Session)**.
- **Is greater than or equal to** `100`.

### Rule 1: Effects

- **Create referral code**:

  - Create it `In the current campaign`.
  - **Redemption limit**: `1`

- **Create notification**:

  - **Type**: `Info`
  - **Title**: `Your referral code!`
  - We include **`[Generated Referral in Session]`** in our message.

## Issue a discount for the referred customer and award loyalty points to the advocate

Let's build a rule to issue a 20% to the customer who redeems the referral code and award
20 loyalty points to the advocate.

Let's name the rule `Redemption rewards`. It has one condition and two effects.

### Rule 2: Condition

**Referral code is valid**.

### Rule 2: Effects

- **Discount session total**: **Name** is `20% off` and **Discount value** is `[Session.Total]*20%`.
- **Add loyalty points**:

  - We select the loyalty program we have created. Let's imagine that it is called `Loyalty points for friends`.
  - **Recipient** is `Advocate`.
  - **Reason** is `Referral code redemption`.
  - **Amount of points** is `20`.

## Create a rule for spending loyalty points

Let's build a rule to allow customers to use their points to pay for new orders when
their loyalty point balance is equal to or greater than the total value of the session. In
this campaign, customers cannot use their points to pay for part of an order.

Let's name the rule `Paying with loyalty points`. It has one condition and one effect.

### Rule 3: Condition

**Check attribute value**: **Current balance (`Loyalty points for friends`) is greater than or
equal to** `Session Total (Current Session)`.

### Rule 3: Effect

**Discount session total**: **Name** is `Pay with points` and **Discount value** is `[Session.Total]`.

## Related pages

- [Referrals overview](/docs/product/campaigns/referrals/referral-overview.md)
- [Basic referral tutorial](/docs/product/tutorials/referrals/basic-referral.md)
