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
The JavaScript Web SDK captures anonymous events by default. However, this may change depending on your person_profiles
config when initializing PostHog:
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.person_profiles: 'always'
- Capture identified events for all events.
For example:
posthog.init('<ph_project_api_key>',{api_host: 'https://us.i.posthog.com',person_profiles: 'always'})
How to capture identified events
If you've set the personProfiles
config to IDENTIFIED_ONLY
(the default option), 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.
Alternatively, you can set personProfiles
to ALWAYS
to capture identified events by default.
Mobile SDK version considerations
When using PostHog's mobile SDKs, any changes made to personProfiles
configuration will only apply to users who have updated their app to the latest version. This is because mobile SDKs are bundled with your app and cannot be updated dynamically.
Impact on existing users:
Users running older versions of your app will continue using the personProfiles
configuration that was bundled with their installed version, even after you release updates with new configurations.
Managing version differences:
To ensure consistent behavior across your user base, you can:
- Use feature flags (with a version payload) to detect users running outdated app versions
- Implement an update flow to guide users to install the latest version
- Consider making app updates mandatory for critical changes
This will help maintain consistency in how person profiles are handled across your entire user base.
Frequently asked questions
General questions
What can I do with anonymous events?
You can:
- Set event properties
- Aggregate and filter events by event properties (e.g. URL, location, UTM source)
- Create insights like trends, funnels, SQL insights and more
You cannot:
- Set person properties
- Create cohorts
- Use Lifecycle insights
- 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 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 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.
Data questions
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.
How are initial person properties set when an anonymous user is identified?
As person properties are not stored on anonymous events, we cannot get any initial person properties directly from those events. Instead, we retrieve the initial person properties based on the values in the persistence store.
We derive the following values from the persistence store:
$initial_current_url
$initial_pathname
$initial_referrer
$initial_referring_domain
$initial_host
- and any initial properties that can be derived from the URL e.g.,
$initial_utm_campaign
,$initial_utm_content
,$initial_utm_medium
,$initial_utm_source
Note that the above initial parameters will only work across subdomains if you're using persistence: "localStorage+cookie"
(default) or persistence: "cookie"
.
Any other initial person properties, including initial GeoIP properties will be set from the values in the event at the time that the person profile was created i.e. when the events became identified.
If we change our `person_profiles` config from `identified_only'`to `always`, will we get all the person data from the previously captured anonymous events?
No, anonymous events only capture the event data and none of the person data. If that person is identified at a later date – either by identifying them or changing your configuration settings – there isn't a way to retrieve the person properties from the previously captured anonymous events.
Insights questions
Are there any insights that behave differently?
Most insights make use of both anonymous and identified events. The exception to this is lifecycle insights, as anonymous events are excluded from this calculation. Users who first appear as 'new' might have had prior anonymous events, but their lifecycle starts only when they are identified.
Why am I seeing "Person without distinct_id" in my insights?
These are users who do not have a person profile and are anonymous users. We're aware that the wording here is confusing and are looking into updating this.
Why am I seeing drops in my insights that rely on person properties?
If you have previously had your person_profiles
config set to always
and your person_profiles
config is now set to identified_only
, you will likely see a dip in your insights graph if the filter settings include a person property.
Insights using person properties in the filter settings will essentially be filtering on identified events, where the person profile linked to that event has the relevant property set.
Changing your person_profiles
config to identified_only
now means that there are fewer person profiles being created and being associated with events, and therefore fewer events to be included in your insight. The person profile won't exist until the person has been identified, which may happen at a later date or not happen at all.
Depending on what you're trying to visualize, you may be able to use some of the properties on the events themselves to achieve a similar outcome – e.g. by filtering on the referring domain on the first ever pageview for each user, instead of the initial referrer person property.
Billing questions
Why are identified events 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. Read this post for more detail on this.
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.