Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 69 additions & 48 deletions contents/docs/product-analytics/trends/filters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@ availability:
enterprise: full
---

import {ProductScreenshot} from 'components/ProductScreenshot'
export const inlineFilterLight = "https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/inline-filter-light-mode.png"
export const inlineFilterDark = "hhttps://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/inline-filter-dark-mode.png"
export const filterGroupsLight = "https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/filter-groups-light-mode.png"
export const filterGroupsDark = "https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/filter-groups-dark-mode.png"
export const internalLight = "https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/internal-and-test-users-light-mode.png"
export const internalDark = "https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/internal-and-test-users-dark-mode.png"

export const FilterIcon = () => <svg class="inline-block w-5 h-5 text-gray" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none"><path d="M10 18H14V16H10V18ZM3 6V8H21V6H3ZM6 13H18V11H6V13Z" fill="currentColor"></path></svg>
import { ProductScreenshot } from "components/ProductScreenshot";
export const inlineFilterLight =
"https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/inline-filter-light-mode.png";
export const inlineFilterDark =
"hhttps://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/inline-filter-dark-mode.png";
export const filterGroupsLight =
"https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/filter-groups-light-mode.png";
export const filterGroupsDark =
"https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/filter-groups-dark-mode.png";
export const internalLight =
"https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/internal-and-test-users-light-mode.png";
export const internalDark =
"https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/user-guides/trends/internal-and-test-users-dark-mode.png";

export const FilterIcon = () => (
<svg
class="inline-block w-5 h-5 text-gray"
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 24 24"
fill="none"
>
<path d="M10 18H14V16H10V18ZM3 6V8H21V6H3ZM6 13H18V11H6V13Z" fill="currentColor"></path>
</svg>
);

Trends support two [types of filters](#types-of-filters):

Expand All @@ -37,12 +54,12 @@ Filters are comprised of three elements, a property, an operation, and a value.

This is the property that you want to filter based on. These properties can be:

- Properties on the event itself
- Properties on the person who sent the event
- Properties on groups that this event is a member of _(see [group analytics](/docs/user-guides/group-analytics))_
- Properties on sessions
- Properties on [cohorts](/docs/user-guides/cohorts) the user is a member of
- Properties on the HTML element if an event was autocaptured
- Properties on the event itself
- Properties on the person who sent the event
- Properties on groups that this event is a member of _(see [group analytics](/docs/user-guides/group-analytics))_
- Properties on sessions
- Properties on [cohorts](/docs/user-guides/cohorts) the user is a member of
- Properties on the HTML element if an event was autocaptured

By default, the dropdown will only show properties that have been seen on a specific event before, but if you instead want to filter based on an unseen property, you can scroll all the way to the bottom of the list and click 'Show X properties that haven't been seen with this event'

Expand All @@ -54,20 +71,20 @@ This is what PostHog uses to compare the property value to determine whether an

Some common operators used in insight filters:

| Name | Description |
| --------------------- | --------------------------------------------------------------------------------------- |
| = equals | The property matches the value exactly and can contain multiple values to match against |
| ≠ doesn't equal | The property _doesn't_ exactly match any of the values you provided |
| ∈ contains | The property contains the value as a substring and can contain multiple values to match against |
| ∉ doesn't contain | The property doesn't contain any of the values you provided as a substring |
| ~ matches regex | The property matches a regex _(only available for strings)_ |
| ≁ doesn't match regex | The property doesn't matches a regex _(only available for strings)_ |
| > greater than | The property is greater than a specific value _(only available for numeric properties)_ |
| &lt; less than | The property is less than a specific value _(only available for numeric properties)_ |
| Name | Description |
| ----------------------- | --------------------------------------------------------------------------------------------------- |
| = equals | The property matches the value exactly and can contain multiple values to match against |
| ≠ doesn't equal | The property _doesn't_ exactly match any of the values you provided |
| ∈ contains | The property contains the value as a substring and can contain multiple values to match against |
| ∉ doesn't contain | The property doesn't contain any of the values you provided as a substring |
| ~ matches regex | The property matches a regex _(only available for strings)_ |
| ≁ doesn't match regex | The property doesn't matches a regex _(only available for strings)_ |
| > greater than | The property is greater than a specific value _(only available for numeric properties)_ |
| &lt; less than | The property is less than a specific value _(only available for numeric properties)_ |
| ≥ greater than or equal | The property is greater than or equal to a specific value _(only available for numeric properties)_ |
| ≤ less than or equal | The property is less than or equal to a specific value _(only available for numeric properties)_ |
| ✓ is set | The property has been set on a specific event |
| ✕ is not set | The property was not set on a specific event |
| ✓ is set | The property has been set on a specific event |
| ✕ is not set | The property was not set on a specific event |

For a complete list of all available operators, including numeric range operators and semver operators for version-based filtering, see the [property filter operators reference](/docs/data/property-filters).

Expand All @@ -82,30 +99,30 @@ Some operations – equals, doesn't equal, contains, and doesn't contain – all
### Inline filters

<ProductScreenshot
imageLight = {inlineFilterLight}
imageDark = {inlineFilterDark}
classes="rounded"
alt="Example inline filter"
imageLight={inlineFilterLight}
imageDark={inlineFilterDark}
classes="rounded"
alt="Example inline filter"
/>

These filters apply to a specific series within a graph. You can apply totally different filters to each series in a trends insight.

To add a filter to a series, click the <FilterIcon /> icon next to the event name, and search for your desired property.
To add a filter to a series, click the <FilterIcon /> icon next to the event name, and search for your desired property.

Currently, inline filters only support with `AND` operations. If you want to include events that match _at least one_ of a group of filters – i.e. `OR` operations – use filter groups.

### Filter groups

Filter groups allow you to apply filters to **all series** within an insight. These filter groups are composed of a number of single filter, which can be combined in the following two ways:

- `AND` – Events have to match _every_ filter within the group
- `OR` – Events only have to match _a single_ filter within the group
- `AND` – Events have to match _every_ filter within the group
- `OR` – Events only have to match _a single_ filter within the group

<ProductScreenshot
imageLight = {filterGroupsLight}
imageDark = {filterGroupsDark}
classes="rounded"
alt="Example global filter"
imageLight={filterGroupsLight}
imageDark={filterGroupsDark}
classes="rounded"
alt="Example global filter"
/>

Click the `+ Add filter group` button to add a filter group. You can add multiple filter groups and you can use `AND` `OR` operators both within and between filter groups.
Expand All @@ -119,13 +136,13 @@ The final option for filtering events is using the option to filter out 'interna
This option is useful for excluding events sent from local builds of your product, or by members of your team that you don't want to include in your analysis.

<ProductScreenshot
imageLight = {internalLight}
imageDark = {internalDark}
classes="rounded"
alt="Filtering internal and test users turned on"
imageLight={internalLight}
imageDark={internalDark}
classes="rounded"
alt="Filtering internal and test users turned on"
/>

Click on the settings icon to go to your project's [Product Analytics settings](https://us.posthog.com/settings/project-product-analytics#internal-user-filtering) to customize the filters that are used.
Click on the settings icon to go to your project's [Customization settings](https://app.posthog.com/settings/project-customization#internal-user-filtering) to customize the filters that are used.

## Filtering by first event occurrence

Expand All @@ -134,9 +151,13 @@ Beyond filtering on properties, you can also specify which event to count for a
This setting is configured per series in a trend insight, in the aggregation dropdown next to the event name.

<ProductScreenshot
imageLight={"https://res.cloudinary.com/dmukukwp6/image/upload/trends_first_ever_light_c49e2aad57.png"}
imageDark={"https://res.cloudinary.com/dmukukwp6/image/upload/trends_first_ever_dark_f2ca1dd21a.png"}
alt="First event occurrence"
imageLight={
"https://res.cloudinary.com/dmukukwp6/image/upload/trends_first_ever_light_c49e2aad57.png"
}
imageDark={
"https://res.cloudinary.com/dmukukwp6/image/upload/trends_first_ever_dark_f2ca1dd21a.png"
}
alt="First event occurrence"
/>

There are two options for this:
Expand All @@ -149,6 +170,6 @@ This option finds a user's very first occurrence of an event type, and then chec

### First occurrence matching filters for user

This option finds the first time a user performed an event type *that also matches your filters*. Previous events of the same type from that user that don't match the filters are ignored.
This option finds the first time a user performed an event type _that also matches your filters_. Previous events of the same type from that user that don't match the filters are ignored.

**Example:** You're filtering for pageview events to `/about`. A user first visited `/pricing` and then later visited `/about`. PostHog ignores the `/pricing` view and counts the `/about` view, as it's the first one that matches the filter.
**Example:** You're filtering for pageview events to `/about`. A user first visited `/pricing` and then later visited `/about`. PostHog ignores the `/pricing` view and counts the `/about` view, as it's the first one that matches the filter.
2 changes: 1 addition & 1 deletion contents/tutorials/filter-internal-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To make it easier to get accurate insights, PostHog includes tools to filter int

## Step 1: Navigate to project settings

PostHog identifies internal users on a project-by-project basis, so head to your project's [Product Analytics settings](https://us.posthog.com/settings/project-product-analytics#internal-user-filtering) to get started. If your PostHog instance spans multiple projects then you must repeat this tutorial for each project.
PostHog identifies internal users on a project-by-project basis, so head to your project's [Customization settings](https://app.posthog.com/settings/project-customization#internal-user-filtering) to get started. If your PostHog instance spans multiple projects then you must repeat this tutorial for each project.

<ProductScreenshot
imageLight={step1Light}
Expand Down
Loading