# Create a community buying campaign

> In community buying campaigns, customers can access a higher discount if a large number of people purchase the same product in a given time span. We can use coupon code redemptions to track how many times the product has been purchased.

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

Let's imagine that we are a fashion brand and want to run a promotion on trousers. We want
as many customers as possible to buy trousers on two specific days in March. To do this, we
[create a standard campaign](/docs/product/campaigns/create-and-manage-campaigns.md#create-a-campaign-from-scratch)
to give customers a 5% discount on trousers if they redeem a valid coupon code on March 13.
We also inform them at checkout that, if they buy more trousers the next day and more than
500 people participate in the campaign, they will receive a 10% discount.

This campaign can be useful to increase customer engagement and the number of orders placed.

Let's create:

1. A [universal coupon code](/docs/product/campaigns/coupons/create-coupons.md#generate-a-universal-code)
   that we have to distribute among our customers before March 13.
1. A [customer profile attribute](/docs/product/account/dev-tools/manage-attributes.md) to ensure
   that only customers who use the coupon on March 13 can get a discount the next day.
1. A [cart item filter](/docs/product/rules/cart-item-filters/overview.md) to filter
   items by item category (in our example, trousers).
1. A [promotion rule](/docs/product/rules/overview.md#promotion-rules) to issue a 5% discount on trousers
   on March 13.
1. A promotion rule to issue a 10% discount on trousers on March 14 for customers who already
   used the coupon code to purchase on March 13.

:::note
The [**Coupons** feature](/docs/product/campaigns/settings/manage-campaign-features.md)
has to be enabled.

The **coupon code is valid** condition redeems the code if the rule is successful. The corresponding
counter in [the **Redemptions** column on the **Coupons** page of the campaign](/docs/product/campaigns/coupons/coupon-page-overview.md#list-coupon-codes-and-gift-cards)
is automatically updated once the session is closed.
:::

## Create a universal coupon code

Let's [create a universal coupon code](/docs/product/campaigns/coupons/create-coupons.md#generate-a-universal-code)
for our customers to receive a discount on March 13. We will use coupon redemptions to track
the total number of purchases on March 13 and which customers are eligible for a discount
on March 14.

- Coupon code: `Trousers13`
- Coupon redemption limit: `Allow unlimited redemptions`
- Per-customer redemption limit: `Allow unlimited redemptions`

## Create a customer profile attribute

Let's [create a custom attribute](/docs/product/account/dev-tools/manage-attributes.md#create-a-custom-attribute)
to indicate whether the given customer is eligible for the community buying discount. We will
set it to `true` if the coupon code is redeemed on March 13.

- Associated entity: `customer profile`
- Attribute type: `boolean`
- API name: `communityEligible`
- Rule Builder name: `Community eligible`
- Rule Builder description: `Determines if the customer is eligible for a community buying discount.`
- Available in our Application.

## Filter the cart items by item category

Let's create a [cart item filter](/docs/product/rules/cart-item-filters/overview.md)
to find all the cart items belonging to the *trousers* category.

**Filter items by conditions**:

- Attribute is **Item category (Item)**.
- **Is equal to** `trousers`.
- **Save as** `trouser_filter`.

## Issue a 5% discount on March 13

Let's [build a rule](/docs/product/rules/create-and-manage-rules.md#create-a-promotion-rule)
for our customers to receive a 5% discount on any trousers in their cart if they redeem
the coupon code on March 13.

Let's name it `5% discount`. It has two conditions and three effects.

### Rule 1: Conditions

- **Coupon code is valid**.
- **Check attribute value**:
  - Attribute is **Current time**.
  - **Is on exact day**: `03/13/2022`.

### Rule 1: Effects

- **Discount individual items**:
  - **List of items** is `trouser_filter`.
  - **Discount name** is `5% off per item`.
  - **Discount value** is <Attribute name="Item.Price" type="builtin" />`* 5%`.
- **Create notification**:
  - **Type** is `info`.
  - **Title** is `trouser community discount`.
  - **Message** is `If more than 500 people redeem this coupon code today, you can use the
    same coupon again tomorrow to get a 10% discount. Share the code with your friends!`
- **Update attribute value**:
  - Attribute is **Community eligible (Customer Profile)**.
  - **Set to value** `True`.

## Issue a 10% discount on March 14

Let's build a rule for our customers to receive a 10% discount on any trousers in their cart
if they redeem the coupon code on March 14 and already used it the day before, and if more
than 500 people participated in this campaign.

Let's name it `10% discount`. It has four conditions and one effect.

### Rule 2: Conditions

- **Coupon code is valid**.
- **Check attribute value**:
  - Attribute is **Total coupon redemptions (Coupon)**
  - **Is greater than** `500`.
- **Check attribute value**:
  - Attribute is **Current time**
  - **Is on exact day** `03/14/2022`.
- **Check attribute value**:
  - Attribute is **Community eligible (Customer Profile)**
  - Value is `True`.

### Rule 2: Effect

**Discount individual items**:

- **List of items** is `trouser_filter`.
- **Discount name** is `10% off per item`.
- **Discount value** is <Attribute name="Item.Price" type="builtin" />`* 10%`.

## Related pages

- [Create a discount using cart item filters](/docs/product/tutorials/coupons/cart-item-filters-discount.md)
- [Use other discount effects](/docs/product/rules/effects/use-effects.md#use-discount-effects)
- [Create a gift card campaign](/docs/product/tutorials/coupons/giftcard.md)
