DEV Community

Arhan Khan
Arhan Khan

Posted on

PostHog for Beginners: Product Analytics You Own

Google Analytics tells you how many people visited. PostHog tells you what they actually did — which button they clicked, where they got stuck, and which feature made them stay. It is an open-source product analytics platform, and the fact that you can self-host it is a big part of the appeal.

The core idea is events. You capture what users do:

import posthog from 'posthog-js';

posthog.init('phc_your_api_key', { api_host: 'https://app.posthog.com' });

// Capture a custom event
posthog.capture('signup_completed', { plan: 'free', source: 'landing_page' });

// Identify the user so events link to a person
posthog.identify('user_123', { email: 'a@example.com' });
Enter fullscreen mode Exit fullscreen mode

From those events you build funnels (how many people finished signup?), retention charts (how many came back after a week?), and session replays (watch a recording of a real user's session to see where they hesitated). Feature flags are built in too, so you can roll a feature out to 10% of users and compare their behavior with the rest.

PostHog's cloud version has a generous free tier — a million events a month — which covers most side projects and small products. If you outgrow it, or you need your data to stay on your own servers for privacy reasons, the open-source version runs in Docker.

The privacy angle matters more than it used to. With third-party cookies dying and regulations tightening, owning your analytics pipeline is a real advantage — and PostHog is one of the few tools that gives you that option without enterprise pricing.

PostHog is for developers and founders who want to understand their product, not just count page views. If you have ever wondered why users sign up and then vanish, this is the tool that answers that question.

Top comments (0)