6 min read

How to Calculate Conversion Rate in PostHog

Conversion rate is the percentage of users who complete a desired action. In PostHog, funnels are purpose-built for this—but only if you're capturing the right events in the right order. Without clean event tracking, you'll get garbage data. Let's set it up correctly.

Capture Events for Your Funnel

PostHog's JavaScript SDK tracks pageviews automatically, but you need explicit events for your conversion funnel. You'll capture at least two: the funnel start (e.g., 'signup_form_viewed') and the completion (e.g., 'signup_completed').

Install and Initialize PostHog

Add the PostHog SDK to your project. Initialize it early—before your app renders—so it captures all events. Find your Project API Key in PostHog Settings > Project > API.

javascript
import posthog from 'posthog-js';

posthog.init('phc_your_api_key_here', {
  api_host: 'https://us.i.posthog.com',
});
Initialize PostHog in your app entry point (e.g., index.js or main.tsx)

Track Funnel Start and Completion Events

Call posthog.capture() when users enter your funnel and when they complete it. Use consistent, lowercase event names with underscores. Add properties (like plan type or traffic source) to segment conversion later.

javascript
// User clicks signup button or views the form
posthog.capture('signup_form_viewed', {
  page: 'homepage',
  utm_source: 'google_ads',
});

// User completes signup
posthog.capture('signup_completed', {
  plan: 'pro',
  signup_method: 'email',
});
Capture both start and completion events with optional properties for segmentation

Verify Events Are Flowing

Go to Data Management > Events in PostHog and search for your event names. You should see them appear within seconds after they fire. If nothing shows up, check browser DevTools for JavaScript errors or confirm your API key is correct.

javascript
// Debug: log to console to confirm capture is firing
posthog.capture('signup_form_viewed');
console.log('Event captured'); // check your browser console
Verify event capture is working before building your funnel
Watch out: If you use different event names in different places ('signup' in one flow, 'user_signup' in another), PostHog treats them as separate events and your funnel breaks. Standardize naming first.

Build a Funnel and Read Conversion Rate

Once events are flowing, creating a funnel takes two minutes. PostHog calculates conversion rate automatically as a percentage at each step and overall.

Create a New Funnel Insight

Go to Insights > New Insight and select Funnel. PostHog will show you a dropdown to add events. Add them in the exact order users experience them.

javascript
// In the PostHog UI, add these steps in order:
// Step 1: signup_form_viewed
// Step 2: signup_completed
//
// PostHog measures only users who hit these events in sequence
// and calculates conversion rate = (step 2 count / step 1 count) × 100
Funnel sequence defines the user journey PostHog measures

Add Time Windows and Filters

Set Time Between Steps (e.g., 'completed within 7 days') to exclude users who signed up but never verified. Add filters like Property: plan equals 'pro' to compare conversion across segments.

javascript
// Example funnel configuration:
// Step 1: signup_form_viewed
// Step 2: signup_email_verified (within 1 day of step 1)
// Step 3: signup_completed (within 7 days of step 1)
//
// Filter by property: utm_source = 'organic' to see conversion for organic traffic only
Funnels with time windows and property filters show conversion for specific user segments

Interpret the Conversion Numbers

PostHog displays conversion as a percentage between each step and overall. For example: 1000 users viewed signup → 700 verified (70% conversion) → 600 completed (85% from step 2, 60% overall). Click any step to drill into which user segments drop off.

javascript
// Sample PostHog funnel output:
// Step 1 - signup_form_viewed: 1,000 users
// Step 2 - signup_email_verified: 750 users (75% conversion)
// Step 3 - signup_completed: 600 users (80% from step 2)
// Overall conversion rate: 60%
//
// Click on step 2 to see which users dropped off before verification
PostHog funnel shows drop-off at each stage and overall conversion
Tip: Pin your most-watched funnels to the dashboard so you see conversion trends without digging into Insights each time.

Calculate Conversion with SQL for Advanced Cases

Funnels assume a strict linear path. If users can skip steps or complete actions out of order, write a SQL query instead to count whoever hits both conditions.

Use SQL Insights for Non-Linear Conversion

In Insights, select SQL Query. Write a COUNT DISTINCT query that divides completions by starts. This counts any user who hit both events, regardless of order.

javascript
SELECT
  COUNT(DISTINCT user_id) as total_users,
  COUNT(DISTINCT CASE WHEN event = 'signup_completed' THEN user_id END) as signups,
  ROUND(100.0 * COUNT(DISTINCT CASE WHEN event = 'signup_completed' THEN user_id END) / 
        COUNT(DISTINCT user_id), 2) as conversion_rate_pct
FROM events
WHERE event IN ('signup_form_viewed', 'signup_completed')
  AND timestamp > now() - interval '30 days'
GROUP BY utm_source;
SQL query to calculate conversion rate grouped by traffic source over 30 days
Watch out: SQL queries don't enforce order—they count any user who hit both events. If you need strict sequencing, use a funnel instead.

Common Pitfalls

  • Mismatched event names across your codebase ('signup' vs. 'user_signup', 'complete_signup') cause PostHog to treat them as separate events, breaking your funnel.
  • Initializing PostHog after your app renders means events fired during page load won't be captured.
  • Forgetting to set a time window between funnel steps—a 7-day gap might inflate completion counts by including users from weeks ago.
  • Using a funnel when your user journey isn't strictly linear—switch to SQL COUNT DISTINCT queries for flexible conversion logic.

Wrapping Up

Conversion rate in PostHog boils down to two things: clean event tracking and a properly ordered funnel. Once you have the baseline numbers, segment by cohort, geography, or traffic source to find where you're losing users. If you want to track conversion across multiple analytics tools and surface anomalies automatically, Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free