7 min read

How to Track Conversion Rate in PostHog

Conversion rate is one of the metrics teams obsess over, but measuring it accurately requires capturing the right events at each step. PostHog gives you two main paths: Funnels for tracking step-by-step user journeys, and Events & Segmentation for flexible custom calculations. Here's how to set both up.

Set Up Event Tracking for Your Conversion Funnel

Before you measure conversion rate, you need to capture the events that make up your funnel—from initial awareness to purchase.

Initialize PostHog and start capturing events

Install the PostHog SDK and initialize it with your project token. The SDK automatically tracks pageviews and lets you send custom events when users take key actions.

javascript
import posthog from 'posthog-js';

posthog.init('phc_YOUR_PROJECT_TOKEN', {
  api_host: 'https://us.i.posthog.com',
});

posthog.pageview();
Initialize PostHog early in your app. Use your actual project token from PostHog settings.

Capture events for each funnel step

Define the key moments in your conversion journey: viewed product, added to cart, clicked checkout, completed purchase. Call posthog.capture() whenever each event happens.

javascript
// Step 1: User views a product page
posthog.capture('product_viewed', {
  product_id: 'prod_123',
  price: 99.99,
});

// Step 2: User adds item to cart
posthog.capture('item_added_to_cart', {
  product_id: 'prod_123',
  cart_total: 99.99,
});

// Step 3: User completes purchase
posthog.capture('purchase_completed', {
  product_id: 'prod_123',
  revenue: 99.99,
});

Attach properties to identify user segments

Use posthog.people.set() to store lasting user properties like company size, signup source, or plan tier. This lets you calculate conversion rate separately for each segment.

javascript
posthog.people.set({
  email: '[email protected]',
  company_size: 'enterprise',
  signup_source: 'organic_search',
  plan_tier: 'premium',
});
Tip: Use snake_case for event names (product_viewed, not productViewed) to keep your event library consistent and searchable in PostHog.

Calculate Conversion Rate with Funnels

The Funnels feature shows exactly how many users progress through each step and where they drop off.

Create a new funnel in PostHog

Go to Insights > Funnels and click New funnel. Add your steps in order: product_viewed → item_added_to_cart → purchase_completed. PostHog calculates the conversion rate between each step automatically.

javascript
// PostHog Funnel Example:
// Step 1: product_viewed (1000 users)
// Step 2: item_added_to_cart (400 users) = 40% conversion
// Step 3: purchase_completed (80 users) = 20% conversion from step 2, 8% overall

// Each row shows: users at step, % who made it from previous step

Filter your funnel by user segments

Click Filters above your funnel steps. Filter by company_size, signup_source, or any property you set with posthog.people.set(). This shows conversion rates for specific audiences.

javascript
// In PostHog: Add filter "company_size = enterprise"
// Shows conversion rates ONLY for enterprise customers
//
// Then compare by creating another filter for "company_size = startup"
// You'll see if one segment converts significantly better

Analyze time to conversion

The Funnels view includes Time to convert breakdown. This shows how long users take between steps. Users who take weeks to convert might be researching; those who convert instantly might be high-intent.

javascript
// PostHog shows median time between steps:
// product_viewed → item_added_to_cart: 2 hours (median)
// item_added_to_cart → purchase_completed: 30 minutes (median)
//
// Longer times = longer sales cycle or hesitation
Watch out: Funnels require users to hit steps in exact order. If your flow is non-linear (some users skip steps or take alternate paths), use Events & Segmentation instead for accuracy.

Calculate Custom Conversion Rates with Formulas

For flexible, non-linear conversions, use PostHog's Events view with custom formulas.

Create a formula to calculate conversion percentage

Go to Insights > Events and select Formula. Divide your completion event by your starting event and multiply by 100. For example: (purchase_completed ÷ product_viewed) × 100.

javascript
// In PostHog Formula bar:
// (purchase_completed / product_viewed) * 100
//
// If 1000 users viewed products and 50 purchased:
// Result = (50 / 1000) * 100 = 5% conversion rate

Group by properties to compare segment performance

Click Group by and select a property like company_size or signup_source. PostHog breaks down your conversion rate for each segment value, showing which audiences convert best.

javascript
// Formula: (purchase_completed / product_viewed) * 100
// Group by: signup_source
//
// Results:
// organic_search: 7% conversion
// paid_ads: 4% conversion
// referral: 12% conversion
// direct: 5% conversion

Pin results to a dashboard for continuous monitoring

Once your formula is set up, click Save and add it to a dashboard. This lets you check conversion trends week-over-week without rebuilding the query.

javascript
// After saving, your dashboard card updates automatically
// You can set date ranges and filters without touching the formula

// Example: Compare conversion rates across different date ranges:
// This month: 6%
// Last month: 5%
// 90 days ago: 4%
Tip: Event-based formulas ignore order, so they're ideal for products where users skip steps or enter at different points in the funnel.

Common Pitfalls

  • Tracking events without properties. A bare capture('click') doesn't tell you anything about which users convert. Always attach relevant data like product_id or customer_tier.
  • Confusing Funnels with Events. Use Funnels only if users *must* hit steps in order. For multi-path journeys or circular flows, Events + formulas are more accurate.
  • Measuring conversion for all users equally. New users and returning users have different behaviors. Always filter by user cohort (new vs. returning) or check both separately.
  • Not accounting for time lag. Some conversions take weeks. If you measure conversion rate for today only, you'll miss users still in the journey. Set your date range wide enough.

Wrapping Up

You now have two ways to measure conversion rate in PostHog. Use Funnels for linear, step-by-step journeys with users who follow the same path. Use Events with formulas for flexibility when users take different routes. The trick is capturing the right events with meaningful properties so you can segment and compare. Once you pick one, monitor it weekly and dig into drop-off—that's where you'll find quick wins. If you want to track conversion rates automatically across PostHog, Amplitude, Mixpanel, and other tools from a single interface, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free