How to Use PostHog: The Beginner's Guide (First Project, First Events, Your First Funnel, and the Flag That Ships Safely)

CodexFuse Team · 2026-10-31T03:57:27.257Z · 14 min read

How to Use PostHog: The Beginner's Guide (First Project, First Events, Your First Funnel, and the Flag That Ships Safely)

Learning how to use PostHog means learning to answer the question every builder asks after launch: what are users actually doing in my product? PostHog is an open-source product analytics platform that tracks events, builds funnels and retention charts, records user sessions, and ships features behind feature flags — all in one tool. Instead of guessing which button nobody clicks or why signups die halfway, you instrument your app once and watch the answers arrive.

This PostHog for beginners tutorial walks the complete arc in one sitting: create your first project, install the JavaScript SDK, send your first events, name them with discipline, connect them to real users with identify, build your first funnel, read retention, watch one session replay safely, and roll out a feature behind a flag. If you want to practice the funnel-analysis mindset before your own data arrives, PostHog funnel analysis lets you paste sample events and find where a funnel leaks, right in your browser.

How Do You Use PostHog? The 30-Second Version

You use PostHog by creating a project, installing its tracking SDK in your app, sending named events for the actions that matter, linking those events to real users, and then reading funnels and retention charts to find the drop-off. The whole beginner loop looks like this:

  1. Create an account and a project at PostHog — a project holds one app or site, so use a separate project for testing and one for production.
  2. Install the SDK — npm install --save posthog-js — and initialize it with your project key and the right cloud host.
  3. Send your first events with posthog.capture() — start with 5 to 10 core actions, not everything.
  4. Identify your users after login with posthog.identify(), so anonymous clicks and signed-in sessions belong to one person.
  5. Build your first funnel in Insights > Funnels to find the step where users drop off.
  6. Watch one session replay of a dropped-off session — with masking on — to see the confusion with your own eyes.
  7. Ship the fix behind a feature flag at a 10% rollout, then watch the funnel move.

What Is PostHog, and What Does It Track?

PostHog is an event-based product analytics platform. Where a traditional analytics tool counts pageviews, PostHog records events — discrete actions like signup_started, checkout_completed, or report_exported — along with properties describing each one. Events are the atoms; everything else in PostHog is built from them.

From those events, PostHog derives four more products on the same platform. Funnels show conversion through multi-step flows. Retention tables show how many users return day after day. Session replay records real user sessions so you can watch where people hesitate. Feature flags and experiments gate releases and run A/B tests with statistical significance. One platform, one install, five answers to "what is happening in my product?"

Should You Use PostHog Cloud or Self-Host PostHog?

Most beginners should start with PostHog Cloud. You sign up, copy a key, and start tracking in minutes — no infrastructure. Self-hosting only pays off when data residency or cost-at-scale becomes the constraint.

Your situationChooseWhy
You want answers this weekPostHog CloudZero infrastructure; generous free tier, no credit card
You must keep data on your serversSelf-hostedMIT-licensed open source; your database, your rules
You are learning how analytics worksPostHog CloudThe free tier covers real beginner projects; upgrade later
You track tens of millions of events monthlySelf-hosted (or compare)At scale, your own infrastructure can be cheaper — do the math

Self-hosting runs on Docker — if that sentence already worries you, read the Docker beginner guide first. The app itself needs a server with real resources, so check what is VPS hosting before you rent one for analytics. This guide follows the Cloud path because it is the beginner path.

How Do You Set Up Your First PostHog Project?

You set up your first project by signing up, creating a project, and copying its project key. A project is the container for one app or site. Create one project for testing and a second for production, so your own test clicks never pollute your real numbers.

Two facts about keys and hosts, straight from PostHog's documentation. The project key — it starts with phc_ — is a public key by design; it identifies your project in client-side code, and PostHog's docs show it in init examples. Store it in an environment variable anyway (NEXT_PUBLIC_POSTHOG_KEY), never hard-coded, because env habits scale to the secrets that actually are secret. And pick the right cloud host during signup: the docs use https://us.i.posthog.com for the US cloud, and the project settings give you the matching host if you choose the EU cloud — events sent to the wrong host silently vanish.

How Do You Install PostHog in Your App?

You install PostHog by adding the package and calling posthog.init() once, before your app code runs. PostHog's official JavaScript docs offer two paths: the HTML snippet (fastest) or the package manager (cleaner for real apps). This guide uses the package path.

npm install --save posthog-js

Then initialize it with your key and host:

import posthog from 'posthog-js'
posthog.init('<ph_project_token>', {
  api_host: 'https://us.i.posthog.com',
  defaults: '2026-08-30'
})

That defaults date is PostHog's config snapshot — it pins which SDK defaults you get, so future SDK updates do not silently change your tracking behavior. One more trap the official docs call out: if your site sets a Content-Security-Policy, allow PostHog's hosts in script-src and connect-src (the SDK lazy-loads replay and survey bundles from PostHog's CDN). Without those allowances, capture calls fail silently and your integration looks complete while zero events arrive.

What Are PostHog Events, and How Many Should You Track?

An event is one recorded user action with a name and optional properties. Tracking starts with autocapture, but the good data comes from the 5 to 10 manual events you name yourself.

Out of the box, PostHog's autocapture records pageviews, clicks, form submissions, heatmaps, and dead clicks — enough to see traffic, never enough to explain it. The discipline is: name a small set of intent events — the actions your product exists for — and capture them explicitly with properties you will actually query.

posthog.capture('checkout_started', { plan: 'pro', price: 29, currency: 'USD' })

A beginner event taxonomy that covers most SaaS apps looks like this:

Event nameWhen it firesKey properties
signup_startedUser opens the signup formsource, plan_selected
signup_completedAccount createdauth_method, plan
onboarding_step_completedEach setup step finishedstep_name, step_number
first_key_actionUser does the product's core thing onceaction_type
upgrade_clickedUser clicks any upgrade CTAplan, source_page
checkout_startedCheckout page reachedplan, price, currency
checkout_completedPayment succeedsplan, revenue, currency
feature_usedA named feature runsfeature_name, via

Naming rules that save you later: lowercase snake_case, past tense for completed actions (checkout_completed, not checkout), and a property for every dimension you will ever filter by — you cannot query a property you never sent. Resist the urge to capture everything on day one; 50 half-named events are a swamp, while 8 well-named events are a dashboard.

How Do You Connect PostHog Events to a Real Person?

You connect events to a person by calling posthog.identify() right after login, with your auth system's stable user ID. PostHog assigns every visitor an anonymous distinct ID automatically; identify merges the anonymous history with the known user, so the clicks from before signup and the actions after belong to one person.

posthog.identify(user.id, { email: user.email, plan: user.plan })
// on logout:
posthog.reset()

Use a stable ID from your auth system — never an email or display name as the ID itself, and never a shared literal like "anonymous", which pools many people onto one person and corrupts their data. Send email and name as person properties instead. If your app stores users in a backend database, the Supabase beginner guide shows where that stable ID lives. And always call posthog.reset() on logout, or the next person on a shared browser inherits the last user's identity.

How Do You Build Your First Funnel?

You build a funnel by choosing the event sequence you care about and letting PostHog show the drop-off at each step. Go to Insights, choose Funnels, and add your steps in order — for example: signup_started > signup_completed > onboarding_step_completed > first_key_action.

Read the result like a doctor reads a chart. If 1,000 people start signup and 400 complete it, your form is the problem. If 400 complete signup and 40 finish onboarding, onboarding is the problem. Fix the biggest drop-off first, ship the fix, and watch the funnel move — that loop is the entire point of product analytics.

PostHog lets you drill into any step to see the actual users who converted or churned. That person-level view turns "the funnel leaks at step 3" into "these 36 users stopped at the billing screen" — a much more fixable sentence.

How Do You Measure Retention in PostHog?

You measure retention with a retention insight: pick an event that means "the user came back and did the thing," then read the table of returning users by day or week. The classic beginner setup is Day 1, Day 7, Day 30 retention on first_key_action or daily app open.

Retention is the metric that separates products from traffic. A funnel tells you about one visit; retention tells you whether anyone comes back. If Day 7 retention is under 10%, no amount of new signups fixes the product — the bucket is leaking faster than you can fill it.

Should You Turn On Session Replay?

Turn on PostHog session replay only after you enable masking and understand sampling. Replay shows you exactly where users hesitate — but it also records what users type and see, so the privacy warning comes before the button.

PostHog masks sensitive inputs by default, and you should verify it masks your password fields, payment fields, and any personal data before enabling replay in production. The docs also support replay triggers — start recording only on specific pages or events — so you are not recording every casual scroll. Replay has its own free allowance (5,000 recordings a month on the free tier, per PostHog's pricing page captured this week), which is plenty for a beginner and a reason to sample rather than record everyone.

How Do Feature Flags Ship Features Safely?

PostHog feature flags let you release code to production while showing it to only some users. You wrap the new behavior in a flag check, roll it out to 10% of users, watch the funnel and error rates, then widen the rollout or roll back with one click.

if (posthog.isFeatureEnabled('new-checkout-flow')) {
  renderNewCheckout()
} else {
  renderOldCheckout()
}

The beginner workflow: create the flag in the PostHog UI, use isFeatureEnabled (or the React hook useFeatureFlagEnabled), set the rollout to 10%, and keep the old code path behind the else until you are sure. Flags also power A/B tests — PostHog splits users across variants and computes statistical significance — but master the safe rollout before the experiment.

PostHog vs Mixpanel vs Google Analytics: Which One Is Yours?

PostHog wins for beginners who want one tool instead of three; Mixpanel wins for teams that already live in its ecosystem; Google Analytics wins for marketing-site traffic. The honest comparison:

QuestionPostHogMixpanelGoogle Analytics
Core question it answersWhat do users do in my product?What do users do in my product?Where does my website traffic come from?
Event trackingYesYesLimited, pageview-first
Funnels and retentionYesYesBasic
Session replayBuilt inSeparate productNo
Feature flagsBuilt inNoNo
Self-hostableYes (MIT-licensed)NoNo
Beginner free tier1M events/month, no cardGenerous free tierFree

The framing that matters: PostHog and Mixpanel answer the same product question, while Google Analytics answers a marketing question. If the posthog vs google analytics debate is why you are here: PostHog tracks product behavior, Google Analytics tracks marketing traffic — most teams eventually run both.

How Much Does PostHog Cost?

PostHog pricing starts at zero and scales with usage. The free tier gives every product its own monthly allowance — verified on PostHog's official pricing page this week: product analytics gets 1 million events a month, session replay gets its own separate allowance, and the tier resets every month. No credit card is required, and usage simply stops at the free limits, so there is no surprise bill.

Two beginner habits keep it that way. First, start with product analytics only — do not enable session replay, error tracking, and every add-on on day one, because each product meters separately. Second, set billing limits per product before real traffic arrives; PostHog lets you cap spend on most products, so a viral moment costs you a setting change, not a funding round.

Sources

Every fact in this guide was verified on 2026-10-30 — making this PostHog tutorial current as of October 30, 2026: PostHog's official pricing page (the first 1M events free every month; generous free tier for each product that resets monthly; no credit card required; usage stops at the free-tier limits so you cannot be charged by surprise; billing limits settable on most products; discounts for startups and non-profits; free tier = 97% of companies with 1 project and 1-year data retention; MIT-licensed open-source product) at posthog.com/pricing; PostHog's official JavaScript web SDK docs (npm install --save posthog-js; the HTML snippet as the recommended alternative; init with <ph_project_token>, api_host: 'https://us.i.posthog.com', and the defaults: '2026-08-30' config snapshot; Content-Security-Policy guidance with script-src and connect-src allowances for lazy-loaded bundles, failing silently without them; identify('your-user-id') required after login with a stable auth-system ID — never an email, display name, or shared literal like "anonymous"; email sent as a person property; posthog.reset() on logout; opt_out_capturing_by_default; replay triggers configurable in project settings) at posthog.com/docs/libraries/js; the 2026 PostHog free-tier guide (each product has its own free allowance as separate buckets — product analytics 1 million events, session replay 5,000 recordings; the five-step setup: separate test/prod projects, tracking snippet, test event, enable only what you need, set spending limits before real traffic) at ampm-aiops.com/en/guides/posthog-howto-2026, updated 20 hours before this guide and verified against the official pricing page; the self-hosted PostHog guide (autocapture covering clicks, form submissions, and pageviews; posthog.capture with properties; posthog.identify plus posthog.reset on logout; feature flags rolled out to 10% of users; server-side tracking with posthog-node; funnels built under Insights > Funnels; Docker self-host via docker-compose.hobby.yml) at dev.to/whoffagents; the PostHog-in-Next.js guide (the React PostHogProvider pattern; manual $pageview capture for SPAs; custom events like checkout_started and checkout_completed; isFeatureEnabled and getFeatureFlag flag checks) at dev.to/whoffagents; and the interactive PostHog walkthrough (the account → SDK → events → funnels → flags arc; free tier framing) at supademo.com/product-demo/posthog. The Cloud-vs-self-host decision table, the beginner event-taxonomy table, and the PostHog-vs-Mixpanel-vs-Google-Analytics comparison are original syntheses for this guide.

Frequently Asked Questions

Is PostHog free?

Yes. PostHog's free tier gives every product its own monthly allowance — 1 million events a month for product analytics — with no credit card required, and usage stops at the limits instead of billing you. Pay-as-you-go only starts when you add a card for higher limits.

Is PostHog open source?

Yes — PostHog ships an MIT-licensed open-source product you can self-host on your own infrastructure, which PostHog's own pricing page confirms. That is why self-hosting is a real option here rather than a marketing claim.

How is PostHog different from Google Analytics?

Google Analytics answers marketing questions — where website traffic comes from. PostHog answers product questions — what users do inside your app — with event tracking, funnels, retention, session replay, and feature flags on one platform. They are complementary, not substitutes.

Is the PostHog project API key secret?

No. The project key (starting with phc_) is a public key by design — it identifies your project in client-side code. Keep it in an environment variable as good hygiene, but the key itself is not a secret; PostHog's docs show it in init examples.

Can I self-host PostHog for free?

Yes, but "free" means you pay with infrastructure instead of a subscription. Self-hosting needs a real server — check what VPS hosting means before renting one — and Docker to run it. Beginners should start on PostHog Cloud and self-host only when data residency or scale makes it the rational choice.

Featured on Twelve Tools Launch Llama Tools Launch your MCP