How to Set Up Product Analytics in PostHog
PostHog is an open-source product analytics platform that gives you full control over your data while providing powerful event tracking, funnel analysis, and session replay capabilities. Unlike hosted solutions, PostHog can run on your own infrastructure, making it a strong choice for teams with strict data residency requirements.
Setting up product analytics correctly from the start prevents months of messy data and unreliable metrics down the line. This guide walks you through the complete PostHog setup process, from installing the SDK to building your first dashboard with actionable product metrics.
Step-by-step guide
Create a PostHog project and install the SDK
Sign up at posthog.com or self-host using their Docker deployment. Create a new project and grab your API key from Project Settings. Install the JavaScript SDK with npm install posthog-js and initialize it in your app entry point with your project API key and instance URL.
- Choose between PostHog Cloud and self-hosted based on your data requirements
- Create a new project and copy the API key from the project settings page
- Install posthog-js via npm and call posthog.init() with your API key in your app bootstrap
Define your event taxonomy before instrumenting
Write out every user action you want to track using a consistent naming convention like object.action (e.g., signup.completed, feature.used, subscription.upgraded). Document each event's properties in a spreadsheet or tracking plan so your entire team instruments events consistently.
- List all critical user actions across your product's core flows
- Adopt a naming convention like object.action and stick to it across every event
- Document required properties for each event including user context and metadata
Instrument key events in your codebase
Use posthog.capture('event_name', { properties }) to track each event you defined. Place capture calls at the point where the action actually succeeds, not when the user clicks — for example, fire signup.completed after the API confirms account creation, not when the form submits.
- Add capture calls in success handlers rather than on button clicks
- Include relevant properties like plan type, feature name, or page context
- Use posthog.identify() on login to link anonymous and authenticated sessions
Set up user identification and properties
Call posthog.identify(userId) when users log in, and use posthog.people.set() to attach persistent properties like plan tier, company name, or signup date. This links pre-login anonymous activity to the authenticated user, giving you a complete picture of the user journey from first visit to conversion.
- Call identify() immediately after successful authentication
- Set person properties for segmentation like plan, role, and company size
- Use posthog.alias() if you need to merge multiple anonymous IDs into one user
Build your first funnel to track activation
Navigate to Insights and create a new Funnel. Add each step in your activation sequence — for example, signup.completed, onboarding.step_viewed, first_project.created, feature.used. Set the conversion window to 7 days and break down by signup source to see which acquisition channels produce users who actually activate.
- Define the 3-5 steps that represent your activation milestone
- Set a realistic conversion window based on your product's typical usage pattern
- Add breakdown properties to identify which segments convert best
Create a product health dashboard
Create a new dashboard and add tiles for DAU/WAU/MAU trends, your activation funnel conversion rate, key feature adoption percentages, and a retention curve. Pin this dashboard so your team sees it daily. Use PostHog's date comparison feature to overlay this week against last week for quick trend detection.
- Add a trends chart for daily active users over the last 30 days
- Include your activation funnel as a funnel visualization tile
- Add retention tables broken down by signup cohort week
Configure session replay and feature flags
Enable session replay in your PostHog project settings to record user sessions for qualitative analysis alongside your quantitative data. Set up feature flags to gate new functionality and measure its impact — PostHog ties flag exposure directly to your analytics events, making it trivial to run experiments.
- Enable session recording and set a sampling rate appropriate for your traffic volume
- Create your first feature flag and wrap a new feature behind it
- Link flag exposure to conversion events to measure the feature's impact
Common mistakes
Tracking too many events too early
Teams often instrument hundreds of events on day one, creating a noisy dataset that nobody uses. Start with 15-20 events covering your core activation and retention loops, then expand once you have questions those events cannot answer.
Firing events on click instead of on success
Capturing a signup.completed event when the signup button is clicked rather than when the API confirms the account was created inflates your numbers and makes funnel data unreliable. Always instrument at the success callback.
Not identifying users before capturing events
If you capture events before calling posthog.identify(), those events are attributed to anonymous IDs and may never get linked to the real user. Initialize identification as early as possible in your authentication flow.
Ignoring property naming consistency
Using plan_type in one event and planType in another creates duplicate properties in PostHog and makes filtering unreliable. Enforce a single naming convention (snake_case is common) across all events and properties.
Tips
Use PostHog's autocapture feature initially to see what users do, then replace it with intentional manual instrumentation once you know what matters
Set up a PostHog action that combines multiple raw events into a single business metric — for example, combining three different payment events into one revenue action
Export PostHog data to your data warehouse using their batch export plugin so your analytics team can join product data with revenue and support data
Use the toolbar's inspect mode to visually verify that events fire correctly on each page before shipping to production
How Vantage helps
Vantage helps PMs define which product metrics matter before diving into PostHog setup. By capturing your product strategy and requirements in one place, Vantage ensures your analytics instrumentation aligns with the questions you actually need answered — not just what is easy to track.