PostHog captures two types of events: anonymous and identified
Identified events enable you to attribute events to specific users, and attach person properties. They're best suited for logged-in users.
Scenarios where you want to capture identified events are:
- Tracking logged-in users in B2B and B2C SaaS apps
- Doing user segmented product analysis
- Growth and marketing teams wanting to analyze the complete conversion lifecycle
Anonymous events are events without individually identifiable data. They're best suited for web analytics or apps where users aren't logged in.
Scenarios where you want to capture anonymous events are:
- Tracking a marketing website
- Content-focused sites
- B2C apps where users don't sign up or log in
Under the hood, the key difference between identified and anonymous events is that for identified events we create a person profile for the user, whereas for anonymous events we do not.
💡 Tip: Under our current pricing, anonymous events can be up to 4x cheaper than identified ones (due to the cost of processing them), so it's recommended you only capture identified events when needed.
How to capture anonymous events
PostHog captures identified events by default. To change this and capture anonymous events, change the person_profiles
config when initializing PostHog:
person_profiles: 'always'
- Capture identified events for all events.person_profiles: 'identified_only'
(recommended) (default) - Anonymous events are captured by default. PostHog only captures identified events for users where person profiles have already been created.
For example:
posthog.init('<ph_project_api_key>',{api_host: 'https://us.i.posthog.com',person_profiles: 'identified_only'})
How to capture identified events
Identified events are captured by default if you've set the person_profiles
config to always
(the default option).
If you've set the person_profiles
to identified_only
, anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
identify()
alias()
group()
setPersonProperties()
setPersonPropertiesForFlags()
setGroupPropertiesForFlags()
When you call any of these functions, it creates a person profile for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
Frequently asked questions
What can and can't I do with anonymous events?
You can:
- Set event properties
- Aggregate and filter events by event properties e.g. URL, geographic location, UTM source.
- Create insights like trends, funnels, SQL insights and more.
You cannot:
- Set person properties
- Create cohorts
- Filter on person properties
- Use person properties for targeting feature flags, A/B tests, or surveys
- Query the
persons
table using SQL insights - Use group analytics
What can and can't I do with identified events?
You can use all of PostHog's features with identified events. There are no restrictions.
What happens to events when an anonymous user is identified?
All future events are associated with their person profile and are captured and billed as identified events.
Past events are attributed to the person, but are otherwise unchanged. This means that past events remain billed as anonymous.
Can identified events still be "anonymous"?
Yes, identified events can still be "anonymous" in the sense that they don't need to contain personal information such as name, email, or phone number. A person profile is still created for them, but it doesn't need to include any personal information.
Can I specify some events to be identified and others to be anonymous for the same users?
Not if you already identified them. Once a user is identified, all future events for that user are associated with their person profile and are captured as identified events.
How do I revert back to anonymous events after identifying?
Calling reset()
will unlink the person profile from the user and create a new PostHog anonymous ID for capturing events. Any future events are captured as anonymous events.
However, if you capture events using the distinct_id
used in their previously identified person profile, the events are captured as identified events. You need to use a new distinct_id
to capture events as anonymous events.
Why are identified events so much more expensive?
Since identified events are associated with a person profile, processing and querying them requires using resource intensive table JOINs. On the other hand, anonymous events are stored in a single table and are more efficient to query.
This post goes into more detail.
Why does PostHog capture identified events by default?
This is required for backwards compatiability. Previously, all events were captured as identified events. When we added anonymous events, we didn't want to change the default behavior since that could cause issues with existing users.
However, since anonymous events are cheaper to capture, we recommend capturing them by default.
Why am I being charged for both "events" and "persons"
We're not charging you for both. The person profiles line item you see on your invoice is a number of identified events captured. The events line item is the total number of anonymous events captured.
How does my free allowance work for anonymous vs identified events?
Your first one million events each month are free, regardless if they are anonymous or identified.