# Filters ## Control which users and events move through your data pipeline. Filters let you decide which users and events enter your workspace and which ones are sent to each destination. You can apply filters both during collection and during activation to keep your data clean, focused, and aligned with your use case. Here are the most common ways filters are used: - **Keep data clean and reliable** Filters help prevent broken or incomplete events from entering the system or reaching destinations, ensuring that user profiles and analytics stay accurate. - **Share only the data you really need** You can exclude sensitive, unused, or non-essential information—either when collecting data or before sending it to external tools—to support privacy and compliance. - **Reduce noise and unnecessary volume** Filters make it easy to remove low-value or high-frequency events, helping both technical teams and marketing teams work with faster, simpler, and more cost-efficient data flows. - **Send the right users and events to the right places** Whether you are enriching data, transforming it, or activating it, filters let you focus on the specific audiences and behaviors that matter for your use case. - **Test safely before going live** You can isolate a small sample of users or events to try out new integrations or workflows without affecting your entire audience. ## Operators In a filter, choose **and** if all conditions must match, or **or** if any condition can match. Here are all the operators you can use in filters. The operators you can use for a property depend on the property. Texts are compared in a case-sensitive manner (e.g., "CA" does not match "ca"). | Operators | | |----------------------------|-------------------------------| | `is` | `is not` | | `is less than` | `is greater than` | | `is less than or equal to` | `is greater than or equal to` | | `is between` | `is not between` | | `contains` | `does not contain` | | `is one of` | `is not one of` | | `starts with` | `ends with` | | `is before` | `is after` | | `is on or before` | `is on or after` | | `is true` | `is false` | | `is empty` | `is not empty` | | `is null` | `is not null` | | `exists` | `does not exist` | ## Best Practices #### Quoted values It is not necessary to quote values. However, if a value starts or ends with a space, `"` or `'`, you should quote it with `"` or `'`. Use a backslash (`\`) to escape `"` or `'` within a quoted value. ```text ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ code ▼ │ │ starts with ▼ │ │ " 'S'" │ ✔ correct └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ code ▼ │ │ starts with ▼ │ │ 'S' │ ✘ invalid └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ``` The second example is invalid because values starting with `'` must be wrapped in quotes. #### Using keys of a JSON property To refer to a key within a JSON object, specify it right after the property name. For example, given the following object: ```json { "address": { "street": "1234 Sunset Blvd", "city": "Los Angeles", "state": "CA", "zip": "90026", "country": "USA" } } ``` To refer to the state, use `address.state` as shown below: ```text ┌───────────────────────────┐ ┌──────────────────┐ ┌──────────┐ ┌──────────┐ │ traits ▼ │ │ address.state │ │ is ▼ │ │ CA │ ✔ correct └───────────────────────────┘ └──────────────────┘ └──────────┘ └──────────┘ ┌───────────────────────────┐ ┌──────────────────┐ ┌──────────┐ ┌──────────┐ │ traits ▼ │ │ "address city" │ │ is ▼ │ │ CA │ ✘ invalid └───────────────────────────┘ └──────────────────┘ └──────────┘ └──────────┘ ``` Make sure you reference nested keys without quotes and using dot notation. #### Check if a JSON property exists To check if a JSON property exists, use the `exists` operator instead of `is null`: ```text ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ │ traits ▼ │ │ name │ │ exists ▼ │ ✔ correct └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ │ traits ▼ │ │ name │ │ is null ▼ │ ✘ invalid └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ ``` #### Check if true Use the `is true` operator if you want a JSON property to be the boolean `true`: ```text ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ │ traits ▼ │ │ active │ │ is true ▼ │ ✔ correct └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ traits ▼ │ │ active │ │ is ▼ │ │ true │ ✘ invalid └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ``` #### Check if empty Use the `is empty` operator to check whether a property is empty, and the `is not empty` operator to check whether it is not. A property is empty in the following cases: * it does not exist * it is `null` * it is an empty `string` * it is an empty `array` * it is an empty `map` * it has type `json` and its value is JSON null, or an empty JSON string, array, or object. ```text ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ │ traits ▼ │ │ email │ │ is empty ▼ │ ✔ correct └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ ┌───────────────────────────┐ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ traits ▼ │ │ email │ │ is ▼ │ │ "" │ ✘ invalid └───────────────────────────┘ └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ``` #### Dates and times Write values representing date and time (`datetime` property type) using one of the following ISO8601 formats: * `YYYY-MM-DDThh:mm:ss` * `YYYY-MM-DDThh:mm:ss.nnnnnnnnn` * `YYYY-MM-DDThh:mm:ss+hh:mm` * `YYYY-MM-DDThh:mm:ssZ` ```text ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ registration_time ▼ │ │ is before ▼ │ │ 2024-09-17T12:34:22.561 │ ✔ correct └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ registration_time ▼ │ │ is before ▼ │ │ 09-07-2024 12:34:22.561 │ ✘ invalid └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ``` Write values representing dates (`date` property type) using the format `YYYY-MM-DD`: ```text ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ date_of_birth ▼ │ │ is after ▼ │ │ 2024-09-17 │ ✔ correct └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ date_of_birth ▼ │ │ is after ▼ │ │ 09/17/2024 │ ✘ invalid └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ``` Write values representing a time in a day (`time` property type) using the format `hh:mm:ss` or, for sub-second precision, `hh:mm:ss.nnnnnnnnn`: ```text ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ event_start_time ▼ │ │ is after ▼ │ │ 10:30:00 │ ✔ correct └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ┌───────────────────────────┐ ┌────────────────┐ ┌────────────────────────────┐ │ event_start_time ▼ │ │ is before ▼ │ │ 10h 30m │ ✘ invalid └───────────────────────────┘ └────────────────┘ └────────────────────────────┘ ```