How to Install PostHog and Track Your First Event

October 30, 2026

PostHog is an open-source product analytics platform: you add a snippet or SDK, call posthog.capture(), and get funnels, retention, session replays, feature flags and A/B tests in one tool. The cloud free tier gives you 1 million events per month.

The pitch is that you stop stitching Mixpanel, Hotjar and LaunchDarkly into one story. That consolidation is real, though PostHog’s depth in each category trails the specialist tools.

What do you need to get started?

A US or EU project at posthog.com, a project API key, and about 10 minutes.

Install the snippet in your HTML head, or the npm package for a proper SPA setup:

npm install posthog-js
posthog.init('phc_YOUR_KEY', {
  api_host: 'https://us.i.posthog.com',
  person_profiles: 'identified_only'
});

That person_profiles: 'identified_only' setting matters for cost. By default PostHog creates a profile per anonymous visitor, and anonymous profiles chew through events fast. Setting it to identified-only cut one team’s usage by 40%.

How should you name events?

Pick a convention on day one, because renaming later means historical data you cannot compare.

Use object_action in past tense: project_created, checkout_completed, invite_sent. Not Clicked Create Button. Not createProject.

Properties go in the second argument, not the event name:

posthog.capture('project_created', {
  template: 'blank',
  plan: 'free',
  team_size: 3
});

Six months from now you will want to filter project_created by plan. If plan is baked into the event name, you are re-instrumenting.

How do you identify users?

Call posthog.identify(userId, properties) after login, and posthog.reset() on logout. Without the reset, the next user on that browser inherits the session and your funnels merge two people.

For server-side events, use the Node or Python SDK with the same distinct ID. That is how you get “user did X in the app and paid via Stripe” in one timeline — Stripe events arriving server-side, product events client-side.

If you use a backend that cannot call the SDK, PostHog’s HTTP capture endpoint works from anywhere with a curl.

What does the free tier actually include?

Product Free allowance
Product analytics 1M events/month
Session replay 5,000 recordings/month
Feature flags 1M requests/month
Surveys 1,500 responses/month
Error tracking 100k exceptions/month

These reset monthly and are per project. Above the limits it is usage-based pricing, roughly $0.00031 per event — so 10M events lands around $2,800/month. Not cheap at scale, which is why the pricing page is the most-read page on their docs.

The generous free tier is genuine, not a 14-day trial. That is the main reason it wins for small teams.

Should you self-host instead?

Yes if data residency is a hard requirement and you have a Kubernetes shop. The posthog Docker Compose setup runs ClickHouse, Kafka, Postgres and Redis — realistically 8 GB of RAM minimum, more like 16 GB to be comfortable.

For a small team, self-hosting costs more in ops time than the cloud bill. Do it because you must, not to save money.

What it does worse than specialists

  • Funnels. Mixpanel’s funnel builder is faster to iterate in; PostHog’s SQL-backed insights need more clicks for the same answer.
  • Session replay. A full-page screenshot recorder like Hotjar feels lighter on the client, and PostHog’s replay adds roughly 40-70 KB of JS.
  • Experiment stats. Bayesian-only. If your team needs frequentist tests for a specific reason, look elsewhere.

And the ad-blocker problem applies to everyone: 15-25% of your traffic blocks the SDK. Always reconcile against your server-side signup count before drawing conclusions from a funnel.

Key Takeaways

  • Init with person_profiles: 'identified_only' to avoid burning events on anonymous profiles.
  • Name events object_action in past tense; put attributes in properties, not the name.
  • Call posthog.identify() on login and posthog.reset() on logout.
  • Free tier: 1M events, 5,000 replays, 1M flag requests per month.
  • Self-hosting needs ~8-16 GB RAM across ClickHouse, Kafka, Postgres and Redis.
Tags: