Cutting product analytics costs

Last updated:

|Edit this page

We aim to be significantly cheaper than our competitors. In addition to our ridiculously cheap pricing, below are tips to reduce your product analytics costs:

Use anonymous events

PostHog captures two types of events: anonymous and identified. 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.

Note: See our docs on person profiles for more information on the differences between anonymous and identified events.

Examples of 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

On the other hand, there are many use cases that don't require person profiles and can use anonymous events, such as:

  • Tracking a marketing website
  • Content-focused sites
  • B2C apps where users don't sign up or log in
  • High volume API server events

How to capture anonymous events

PostHog captures identified events with person profiles by default.

To change this and capture anonymous events in the JavaScript Web SDK, change the person_profiles config option:

  1. person_profiles: 'always' (default) - We capture identified events and person profiles for all events.

  2. person_profiles: 'identified_only' (recommended) - We only capture identified events for users where person profiles are already created. This is triggered by calling functions like identify(), group(), and more. Anonymous events are captured from new users and don't create person profiles.

An example of an updated configuration looks like this:

Web
posthog.init(
'<ph_project_api_key>',
{
api_host: 'https://us.i.posthog.com',
person_profiles: 'identified_only'
}
)

Other SDKs and the API can pass the $process_person_profile property in events. Again, identified events are enabled by default, but you can disable this by setting the property to false.

Below is an example in Node, but the same applies to other SDKs:

Node.js
client.capture({
distinctId: 'distinct_id_of_the_user',
event: 'movie_played',
properties: {
$process_person_profile: false,
},
})

Configure autocapture

Autocapture is a powerful feature that captures many events automatically. It can also capture more than you need. To reduce which events are captured, you can set an allow or ignore list.

Alternatively, you can disable autocapture completely.

Only call identify() once per session

It's only necessary to identify a user once per session. To prevent sending unnecessary events, check posthog._isIdentified() before calling identify():

JavaScript
if (!posthog._isIdentified()) {
posthog.identify('distinct_id') // Replace 'distinct_id' with your user's unique identifier
}

Only call group() once per session

In client-side SDKs, it's only necessary to call group() once per session. Prevent calling it multiple times to send fewer events and reduce costs.

Disable pageview or pageleave events

PostHog automatically captures pageviews and pageleaves. This is great for analytics, but it may capture more events than you need. An alternative is disabling these events and capturing them manually for the pages you need instead.

To disable automatically capturing these events, set capture_pageviews and capture_pageleave to false in the configuration options when initializing PostHog:

JavaScript
posthog.init('<ph_project_api_key>',
{
api_host: 'https://us.i.posthog.com',
capture_pageviews: false,
capture_pageleave: false,
}
)

To manually capture these events, call posthog.capture('$pageview') and posthog.capture('$pageleave').

Note: Disabling pageview and pageleave events may prevent other PostHog features from working, like bounce rate.

Questions?

Was this page useful?

Next article

Trends

Trends insights enable you to plot data from people, events, and properties however you want. They're useful for finding patterns in your data, as well as monitoring your product to ensure everything is running smoothly. Trends is the default insight type in PostHog. What can you learn from trends? Using trends, you can analyze: How your most important metrics change over time. Long-term patterns, or cycles in your usage. How a specific change affects usage. The usage of different features side…

Read next article