> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pocketflows.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How segments and filter definitions work

> How the customer data you sync becomes filters a business can build segments from

A segment is a group of a business's customers, such as "members on the Gold
plan" or "customers who haven't visited in 60 days". Businesses build segments
inside the embed by combining filters. A filter definition is how you tell
Pocketflows which of your customer properties should be offered as filters.

To set one up, see
[Let businesses build segments from your data](https://docs.pocketflows.com/how-to/set-up-segment-filters.md).

## From your data to a segment

Three pieces work together:

1. **Customer properties.** The data itself lives on each customer. Anything you
   sync into a customer's `metadata` can be filtered on, along with the
   customer's built-in properties such as `email_address`.
2. **Filter definitions.** A filter definition describes one property: where to
   find it (`variable_name`), what to call it in the interface (`label`), and
   what kind of value it holds (`type`).
3. **Segments.** In the embed, the business picks from the defined filters and
   sets a condition on each, for example "Membership plan is Gold". The
   customers that match are the segment.

A filter definition holds no customer data. It only describes a property so the
embed can show the right control for it. If you define a filter for a property
you never sync, the filter appears but no customer has a value for it.

The same filters are offered wherever a business narrows an audience in the
embed: when building segments, and when choosing who a campaign or trigger
applies to.

## Why the type matters

The `type` decides which control the business sees and which comparisons it can
make. A `number` can be compared as greater or less than a value, a `datetime`
can be compared to "30 days ago", and a `select` shows a dropdown of the options
you provide.

The type has to agree with the value you actually sync. A `datetime` filter on a
property that holds free text will not match the customers you expect. See
[Filter definitions](https://docs.pocketflows.com/reference/filter-definitions.md#types) for the value each
type expects.

## Project-level and business-level definitions

A filter definition belongs to either your whole project or a single business.

* **Project-level** definitions apply to every business in the project. Use them
  for properties that every business has, such as a membership plan your
  platform defines. You create them in the dashboard, and each one stays hidden
  until you enable it.
* **Business-level** definitions apply to one business. Use them for properties
  that only some businesses have, or whose options differ per business, such as
  each business's own list of locations. You create them with the API, and they
  are enabled as soon as they are created.

When a business has its own definition with the same `variable_name` as a
project-level one, the business's definition replaces the project-level one for
that business. Disabling the business's definition hides the filter for that
business entirely, even though the project-level definition is still enabled for
everyone else.

## Event filters

Filter definitions can also describe the properties of a
[project-defined event](https://docs.pocketflows.com/api-reference/project-defined-events/create-a-project-defined-event.md),
so that a business can narrow a trigger to certain events, such as purchases
over \$100. These use a `variable_name` that starts with `event.` instead of
`customer.` and are created under the event rather than the business.

## Related

* [Let businesses build segments from your data](https://docs.pocketflows.com/how-to/set-up-segment-filters.md)
  for the steps.
* [Filter definitions](https://docs.pocketflows.com/reference/filter-definitions.md) for the fields, types and
  naming rules.
* [How syncing works](https://docs.pocketflows.com/concepts/sync.md) for how customer `metadata` gets into
  Pocketflows.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.