Skip to main content

Analytics in SaaS: PostHog vs Mixpanel vs Custom Events in 2026

·StarterPick Team
posthogmixpanelanalyticssaas2026

TL;DR

PostHog for most SaaS in 2026: replaces Mixpanel + FullStory + LaunchDarkly + Hotjar with one platform, and the free tier (1M events/month) is excellent. Mixpanel if you need advanced funnel analysis and cohort tracking with a dedicated product analytics team. Custom events to your database for simple tracking when third-party analytics is overkill.

What Product Analytics Actually Answers

Without analytics, you're guessing:

  • Why do users sign up but never use the core feature?
  • Where does the onboarding funnel drop off?
  • Which features drive Pro upgrades?
  • Why do churned users leave?

Analytics gives you data to answer these questions — but only if you track the right events.


PostHog: The All-In-One Platform

PostHog is the fastest-growing product analytics platform. It combines:

  • Event analytics (like Mixpanel)
  • Session recording (like FullStory)
  • Feature flags (like LaunchDarkly)
  • Experiments/A/B testing
  • Heatmaps

Free tier: 1 million events/month. This covers most indie SaaS.

// lib/analytics.ts — PostHog client
import PostHogClient from 'posthog-node';

export const posthog = new PostHogClient(
  process.env.NEXT_PUBLIC_POSTHOG_KEY!,
  { host: process.env.NEXT_PUBLIC_POSTHOG_HOST! }
);

// Type-safe event tracking
export function trackEvent(
  event: string,
  userId: string,
  properties?: Record<string, string | number | boolean>
) {
  posthog.capture({
    distinctId: userId,
    event,
    properties,
  });
}
// Client-side — auto-track pageviews + capture events
'use client';
import { usePostHog } from 'posthog-js/react';

export function UpgradeButton({ plan }: { plan: string }) {
  const posthog = usePostHog();

  const handleClick = () => {
    posthog.capture('upgrade_clicked', {
      plan,
      location: 'pricing_page',
      $current_url: window.location.href,
    });
  };

  return <button onClick={handleClick}>Upgrade to {plan}</button>;
}

Critical Events to Track

Every SaaS should track these events at minimum:

// lib/analytics-events.ts — standardized event names
export const Events = {
  // Acquisition
  USER_SIGNED_UP: 'user_signed_up',
  USER_SIGNED_IN: 'user_signed_in',

  // Activation
  ONBOARDING_STARTED: 'onboarding_started',
  ONBOARDING_COMPLETED: 'onboarding_completed',
  FIRST_CORE_ACTION: 'first_core_action',  // First time user uses main feature

  // Retention
  DASHBOARD_VIEWED: 'dashboard_viewed',
  CORE_FEATURE_USED: 'core_feature_used',

  // Revenue
  UPGRADE_CLICKED: 'upgrade_clicked',
  CHECKOUT_STARTED: 'checkout_started',
  CHECKOUT_COMPLETED: 'checkout_completed',
  PLAN_UPGRADED: 'plan_upgraded',
  PLAN_CANCELLED: 'plan_cancelled',

  // Sharing/Viral
  INVITE_SENT: 'invite_sent',
} as const;

// Usage
trackEvent(Events.PLAN_UPGRADED, userId, {
  from_plan: 'free',
  to_plan: 'pro',
  method: 'stripe_checkout',
  mrr_added: 29.99,
});

PostHog Funnel Analysis

Once events are tracked, PostHog shows the drop-off at each step:

Onboarding Funnel:
Sign Up → Verify Email → Connect Account → First Action → Invite Team

Results:
100 users signed up
 82 verified email       (82% → focus: reduce friction here)
 45 connected account    (55% → BIG drop: investigate connection flow)
 30 took first action    (67% → okay)
 12 invited team member  (40% → growth lever)

This tells you where to invest engineering time.


Mixpanel: The Analytics Specialist

Mixpanel is purpose-built for product analytics. More powerful funnel/cohort features than PostHog, but only does analytics (no session recording, no feature flags).

import Mixpanel from 'mixpanel';

const mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN!);

// Event tracking
mixpanel.track('Plan Upgraded', {
  distinct_id: userId,
  from_plan: 'free',
  to_plan: 'pro',
  revenue: 29.99,
});

// User identification with traits
mixpanel.people.set(userId, {
  $email: user.email,
  $name: user.name,
  plan: 'pro',
  upgrade_date: new Date().toISOString(),
  $revenue: 29.99,
});

Choose Mixpanel when:

  • Dedicated product analytics team that needs advanced cohort analysis
  • Need complex behavioral cohorts (users who did X but not Y in last 30 days)
  • Already using Mixpanel across your organization
  • Budget is fine ($25/month for growth plan)

Custom Event Tracking (Simplest)

For early-stage SaaS, storing events in your own database is often enough:

model AnalyticsEvent {
  id         String   @id @default(cuid())
  event      String
  userId     String?
  properties Json     @default("{}")
  createdAt  DateTime @default(now())

  @@index([event, createdAt])
  @@index([userId, createdAt])
}
// lib/track.ts — store events in PostgreSQL
export async function track(
  event: string,
  userId: string | null,
  properties?: Record<string, unknown>
) {
  await prisma.analyticsEvent.create({
    data: { event, userId, properties: properties ?? {} },
  });
}

// Query: how many upgrades this week?
const upgrades = await prisma.analyticsEvent.count({
  where: {
    event: 'plan_upgraded',
    createdAt: { gte: subDays(new Date(), 7) },
  },
});

When custom tracking is enough:

  • Simple event counts (signups, upgrades, feature usage)
  • You'll query it with SQL
  • Total events < 1M/month (won't strain Postgres)
  • Team is comfortable writing SQL queries

When to upgrade to PostHog:

  • Need visual funnel analysis without writing SQL
  • Need session recording to understand user behavior
  • Need feature flags tied to analytics

Boilerplate Analytics Defaults

BoilerplateAnalyticsProvider
ShipFastVercel Analytics (basic)
Supastarter
MakerkitPostHog
T3 Stack
Open SaaSPostHog + Plausible

Find boilerplates with analytics setup on StarterPick.

Check out this boilerplate

View PostHog on StarterPick →

Comments