# Customer segmentation

Show a different cancellation flow to each group of customers.

## The idea

Not every customer should see the same cancellation flow. A customer on a yearly Pro plan who has been with you for two years is worth a different offer than someone on a monthly trial who joined last week. Segmentation lets you describe a group of customers with conditions, and give that group its own flow with its own survey and offers. You can create as many segments and flows as you need; everyone who matches no segment sees your default flow.

## How it works

On each flow you add the conditions that decide who sees it — either a single condition or several, combined with **and** / **or** — and the **Sample Size** chart shows how many customers match as you build.

![Two conditions combined with And, and the live sample size.](https://churnsolution.com/wp-content/themes/astra-child/assets/images/docs/cf-conditions-multi.png)

Prefer to watch? [Customer segmentation walkthrough on YouTube](https://www.youtube.com/watch?v=uBfVr978DQA).

## Attributes you can segment on

- Plan
- Product
- Subscription status
- Subscription price
- Billing interval
- Subscription start date
- Subscription age (months)
- Subscription remaining age
- Subscription discount
- Customer address
- Shipping address
- Date of session opening

Plus any **custom attribute** you define (below). Availability varies slightly by gateway; the Audience step only shows attributes your gateway provides.

## Custom attributes

Segment on anything your gateway does not know about: whether a customer already extended their trial, their activity level, their plan tier, a flag from your own database.

1. **Create the attribute**

   Under **Settings → Configuration → Custom Attributes**, or directly from the Conditions step, add an attribute with a **Label**, a **Key** (the name you will pass at launch) and a **Type**: Text, Number, Date or Boolean. Click **Save**.

   ![Custom Attributes: label, key and type.](https://churnsolution.com/wp-content/themes/astra-child/assets/images/docs/cf-custom-attr.png)

   ![Attribute types: Text, Number, Date, Boolean](https://churnsolution.com/wp-content/themes/astra-child/assets/images/docs/cf-custom-attr-types.png "The four attribute types.")

2. **Use it in a segment**

   The attribute now appears in the **Condition** list of every flow. For example: customers whose *Extended Free trial* is **True** get a flow without a trial-extension offer.

   ![Using the custom attribute as a flow condition.](https://churnsolution.com/wp-content/themes/astra-child/assets/images/docs/cf-custom-attr-condition.png)

3. **Pass the value at launch**

   Include it under `options.customerAttributes` when you call `run()`.

```js
window.churnSolution?.run({
  authKey, subscriptionId, appId: 'APP_ID',
  options: {
    customerAttributes: {
      Has_Extended_Free_Trial: false, // or true, based on the customer's status
    },
  },
});
```

### Using metadata you already have

If the value already exists in your customer or subscription metadata in the gateway, create the custom attribute with the same key and data type and you do not need to pass anything at launch. When a customer opens the flow, Churn Solution uses, in order:

1. The value passed in `customerAttributes`, if any

2. The subscription's metadata

3. The customer's metadata

WordPress-plugin merchants (WooCommerce, PMPro) use the metadata route, since there is no launch call to pass values in.
