How to Set Up PostHog for a SaaS Founder
Step-by-step PostHog setup for SaaS founders. Install, configure events, and track user behavior in under 30 minutes. No fluff, just results.
Why PostHog Matters for SaaS Founders
You shipped. Users are trickling in. But you have no idea what they're doing on your site. Google Analytics shows pageviews. That's not enough. You need to see behavior—which features users click, where they drop off, what drives conversions.
PostHog gives you that. It's product analytics built for founders who move fast. No agency contracts. No six-month implementations. You can have it running in 30 minutes and start collecting real data on day one.
The brutal truth: most founders skip analytics setup entirely. They ship, iterate on gut feel, and wonder why growth stalls. PostHog fixes that. It's the tool that lets you see what's actually happening instead of guessing.
This guide walks you through installation, event capture, and the critical setup decisions that separate working analytics from noise. We'll cover the stack you're likely using—Next.js, React, Node.js—and show you exactly what to track from day one.
Prerequisites: What You Need Before Starting
Before you install PostHog, make sure you have these in place:
Technical Requirements:
- A SaaS app or website (Next.js, React, Node.js, or any JavaScript framework)
- Access to your codebase and ability to deploy changes
- A PostHog account (free tier is plenty to start)
- 30 minutes of uninterrupted time
Knowledge Assumptions:
- You can modify your app's main layout or entry point
- You understand environment variables
- You know how to deploy code to production
Optional but Helpful:
- A basic understanding of how analytics SDKs work
- Familiarity with your framework's documentation
- Access to your site's existing analytics (we'll connect PostHog alongside Google Analytics)
If you're already tracking with Google Analytics, that's fine—PostHog complements it. In fact, we recommend setting up Google Search Console in 10 minutes and GA4 from day one alongside PostHog so you have a complete picture of organic traffic and user behavior.
Step 1: Create a PostHog Account and Get Your API Key
Start here. No account, no analytics.
What You're Doing: Setting up your PostHog workspace and grabbing the credentials you'll need to connect your app.
- Go to posthog.com and click "Get started free."
- Sign up with your email or GitHub account (GitHub is faster if you're a founder who ships).
- Create a new project. Name it something obvious like "Your App - Production" or "Your App - Staging."
- PostHog will ask where you want to host your data. Use the default (US cloud) unless you have data residency requirements.
- After project creation, you'll land on the setup wizard. Don't close it yet—you need the API key.
- Look for the Project API Key in the setup wizard or in your project settings (gear icon → Project → API Keys). Copy it. You'll need this in the next step.
Pro Tip: Create separate PostHog projects for staging and production. This keeps test data from polluting your analytics. You can always merge them later, but separating early saves headaches.
What's Happening: PostHog is creating an isolated workspace for your analytics. Your API key is the bridge between your app and PostHog's servers. Guard it like a password, but it's not sensitive in the way a database credential is—it's meant to be used from the browser and server.
Step 2: Install the PostHog SDK in Your Codebase
This is where the real work starts. The installation process depends on your stack, but the principle is the same: you're adding PostHog's JavaScript SDK to your app so it can start listening for user interactions.
For Next.js Apps (App Router)
Next.js is the most common stack for indie SaaS founders, so we'll start here.
Install the PostHog package:
npm install posthog-jsCreate a new file at
app/providers.tsx(orapp/providers.jsif you're not using TypeScript):'use client' import { PostHogProvider } from 'posthog-js/react' import posthog from 'posthog-js' import { useEffect } from 'react' if (typeof window !== 'undefined') { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, loaded: (ph) => { if (process.env.NODE_ENV === 'development') ph.debug() }, }) } export function PostHogProvider({ children }) { return ( <PostHogProvider client={posthog}> {children} </PostHogProvider> ) }Wrap your root layout with the provider. In
app/layout.tsx:import { PostHogProvider } from './providers' export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( <html> <body> <PostHogProvider> {children} </PostHogProvider> </body> </html> ) }Add your PostHog credentials to
.env.local:NEXT_PUBLIC_POSTHOG_KEY=your_api_key_here NEXT_PUBLIC_POSTHOG_HOST=https://us.posthog.comDeploy. PostHog will start capturing events immediately.
Why This Works: PostHog's SDK automatically captures pageviews and basic events (clicks, form submissions) out of the box. You don't need to manually track every interaction. The 'use client' directive tells Next.js this is client-side code, which is what you need for browser-based analytics.
For React (Non-Next.js)
If you're using Create React App or a custom React setup:
Install PostHog:
npm install posthog-jsInitialize it in your
index.jsormain.jsx:import posthog from 'posthog-js' posthog.init( process.env.REACT_APP_POSTHOG_KEY, { api_host: 'https://us.posthog.com', } )Wrap your app with PostHogProvider (if using React Router or similar):
import { PostHogProvider } from 'posthog-js/react' <PostHogProvider client={posthog}> <App /> </PostHogProvider>
For Node.js / Server-Side Apps
If you're capturing events from your backend (recommended for critical conversions):
Install the Node SDK:
npm install posthogInitialize in your server code:
const { PostHog } = require('posthog') const posthog = new PostHog( process.env.POSTHOG_API_KEY, { host: 'https://us.posthog.com' } )Capture events from critical actions (user signup, payment processed, etc.):
posthog.capture({ distinctId: user.id, event: 'user_signed_up', properties: { plan: user.plan, signup_source: 'organic', }, })
For detailed framework-specific setup, the official PostHog installation guide covers Next.js, React, Vue, and more. You can also check the PostHog integration guide for Vercel if you're deploying on Vercel, or the Remix guide if you're using Remix.
Common Mistake: Forgetting the NEXT_PUBLIC_ prefix on environment variables in Next.js. Without it, PostHog won't initialize on the client. Double-check this if you deploy and see no data.
Step 3: Verify PostHog Is Capturing Data
You've installed the SDK. Now make sure it's actually working.
- Deploy your changes to production (or your staging environment).
- Go to your app and click around. Trigger a few pageviews and interactions.
- Open PostHog in a new tab and go to Activity → Events.
- You should see events rolling in within 10-15 seconds. Look for
$pageviewevents (automatic) and any custom events you've already defined.
If You See Nothing:
- Check your browser's DevTools (F12 → Network tab). Look for requests to
posthog.com. If they're being blocked, you may have a CSP (Content Security Policy) issue. Addposthog.comto your CSP allowlist. - Verify your API key is correct in your environment variables.
- Make sure you're looking at the right PostHog project. Check the project name in the top-left corner.
- Check the browser console for errors. PostHog logs debug info if you enable it.
If You See Data: Great. You're capturing events. Move to the next step.
Step 4: Define Your Event Taxonomy and Custom Events
Automatic events are a start, but they don't tell you why users are on your site. You need custom events.
This is where most founders mess up. They either:
- Track too much (every click on every button) and drown in noise.
- Track too little and miss critical signals.
The sweet spot: track the events that reveal intent and value.
The Founder's Event Taxonomy
Start with these five event categories:
1. Signup/Onboarding Events
user_signed_up(with properties:signup_source,plan)onboarding_startedonboarding_completedfirst_feature_used
2. Core Product Events
feature_used(with property:feature_name)content_created(with property:content_type)search_performed(with property:query)filter_applied(with property:filter_type)
3. Conversion Events
upgrade_initiated(with property:from_plan,to_plan)payment_completed(with property:amount,plan)trial_startedtrial_ended
4. Engagement Events
video_played(with property:video_title)doc_viewed(with property:doc_title)help_requestedfeedback_submitted
5. Churn Events
subscription_cancelled(with property:reason)account_deletedlast_active_date(track in your database, sync to PostHog)
How to Implement Custom Events
Once you've defined your taxonomy, add the events to your code.
In React/Next.js:
import posthog from 'posthog-js'
// When a user signs up
posthog.capture('user_signed_up', {
signup_source: 'organic',
plan: 'starter',
})
// When a feature is used
posthog.capture('feature_used', {
feature_name: 'export_to_csv',
})
// When a payment is processed
posthog.capture('payment_completed', {
amount: 99,
plan: 'pro',
currency: 'usd',
})
In Node.js (backend):
posthog.capture({
distinctId: user.id,
event: 'payment_completed',
properties: {
amount: 99,
plan: 'pro',
currency: 'usd',
},
})
Pro Tip: Capture critical events like payments and signups from your backend, not the frontend. The backend is more reliable and harder for users to block with ad blockers.
For a deeper dive on event design, check out the PostHog tutorial for beginners, which covers event taxonomy and dashboard setup in detail.
Step 5: Set Up User Identification
Right now, PostHog sees anonymous visitors. You need to connect those visitors to actual users so you can track their journey from first visit to paying customer.
Why This Matters: Without user identification, you can't answer: "What did this user do before they signed up?" or "How many free users converted to paid?"
Identify Users After Signup
In React/Next.js:
import posthog from 'posthog-js'
// After successful signup or login
posthog.identify(
user.id, // unique user identifier
{
email: user.email,
name: user.name,
plan: user.plan,
signup_date: user.created_at,
mrr: user.monthly_recurring_revenue,
}
)
In Node.js (backend):
posthog.identify({
distinctId: user.id,
properties: {
email: user.email,
name: user.name,
plan: user.plan,
signup_date: user.created_at,
},
})
Update User Properties When They Change
When a user upgrades their plan or updates their profile, sync it to PostHog:
posthog.people.set({
plan: 'pro',
upgrade_date: new Date().toISOString(),
})
This keeps your user properties in sync and lets you segment by plan, cohort, or any other property.
Step 6: Build Your First Dashboard
Now you have data. Time to make sense of it.
PostHog dashboards are where insights live. You'll use them to answer questions like:
- How many users are signing up per day?
- What's our conversion rate from free to paid?
- Which features are most used?
- Where are users dropping off?
The Founder's Essential Dashboard
- Go to Dashboards in PostHog and click New dashboard.
- Name it "Founder Metrics" or "Core KPIs."
- Add these insights:
Insight 1: Daily Signups
- Event:
user_signed_up - Chart type: Line graph
- Breakdown: None
- This shows your signup velocity.
Insight 2: Feature Usage (Top 5)
- Event:
feature_used - Chart type: Bar chart
- Breakdown: By property
feature_name - This shows which features users actually use.
Insight 3: Conversion Funnel (Free to Paid)
- Step 1:
user_signed_up - Step 2:
trial_started(orupgrade_initiated) - Step 3:
payment_completed - This shows your conversion leaks.
Insight 4: User Retention (Cohort)
- Cohort: Users who signed up
- Metric: Any core event (e.g.,
feature_used) - This shows how many users come back.
Insight 5: Payment Revenue (Cumulative)
- Event:
payment_completed - Sum property:
amount - This shows your MRR trajectory.
Add these to your dashboard and pin it. Check it weekly. This is your north star.
Step 7: Connect PostHog to Your Other Analytics Tools
PostHog is powerful, but it's not an island. Connect it to your existing stack for a complete picture.
Link PostHog with Google Analytics
PostHog captures behavior. Google Analytics captures organic traffic and conversions. Together, they tell the full story.
You're already using Google Search Console to track rankings and search impressions. Now connect it to GA4, and then sync GA4 events to PostHog for a unified view.
The process:
- Set up GA4 tracking from day one.
- Link GA4 with Google Search Console so you see search queries directly in GA4.
- In PostHog, you can export events to GA4 using webhooks or integrations (check PostHog's integration marketplace).
This gives you: organic traffic source → user behavior → conversion. The full funnel.
Set Up PostHog Webhooks for Critical Events
When something critical happens (a payment, a churn signal), you might want to trigger an action outside of PostHog. Use webhooks.
- Go to Project Settings → Webhooks.
- Add a new webhook for your critical events (e.g.,
payment_completed). - Point it to your backend endpoint.
- Your backend can then send a Slack notification, trigger an email, update your database, etc.
Example webhook payload:
{
"event": "payment_completed",
"distinctId": "user_123",
"properties": {
"amount": 99,
"plan": "pro"
},
"timestamp": "2024-01-15T10:30:00Z"
}
Step 8: Enable PostHog Session Recording (Optional but Powerful)
Session recording lets you watch what users actually do on your site. It's like having a screen recorder for every user.
Fair Warning: Session recording can be privacy-sensitive. Make sure your privacy policy discloses this, and consider disabling recording for certain pages (like payment forms).
Enable Session Recording
- Go to Project Settings → Session Recording.
- Toggle it on.
- Set sampling (e.g., record 10% of sessions to save bandwidth).
- Exclude sensitive pages (payment, admin, etc.).
Watch a Session
- Go to Recordings in PostHog.
- Click any session to watch it.
- Look for where users get stuck or confused.
- Use this to improve your UX.
Pro Tip: Watch sessions from users who churned or didn't convert. You'll see the exact moment they gave up.
Step 9: Segment Your Users and Run Experiments
PostHog's real power is segmentation. You can slice your data by any property (plan, signup source, feature usage, etc.) and see how different groups behave.
Create a Segment
- Go to Cohorts.
- Click New cohort.
- Define it by properties. Example: "Users on Pro plan who used the export feature."
- Save it.
- Use this cohort in your insights and dashboards.
Run an A/B Test
PostHog has built-in A/B testing. Use it to test changes before rolling them out to everyone.
- Go to Experiments.
- Create a new experiment.
- Define your test (e.g., "Test new onboarding flow").
- Set your variant (e.g., 50% old flow, 50% new flow).
- Pick your success metric (e.g.,
onboarding_completed). - Run it for 1-2 weeks.
- PostHog will tell you which variant wins.
Step 10: Review Your Data Weekly
Data is only useful if you act on it. Set a weekly review habit.
Your Weekly PostHog Review (15 minutes):
- Check your dashboard. Are signups up or down? Is your conversion rate stable?
- Look for anomalies. Did something change unexpectedly? (A feature broke? A blog post went viral?)
- Review your top events. Which features are users using most? Which are they ignoring?
- Watch 2-3 sessions. Pick a user who converted and one who didn't. What's the difference?
- Update your roadmap. Based on what you see, what should you build next?
For a structured approach, check out the quarterly SEO review process that founders use—the same rigor applies to product analytics. Also, if you're tracking SEO performance alongside product metrics, review the 5 GA4 reports every busy founder should bookmark to see how organic traffic feeds into your product funnel.
Common PostHog Setup Mistakes and How to Avoid Them
Mistake 1: Tracking Everything
You'll be tempted to create an event for every button click. Don't. You'll drown in noise.
Fix: Stick to your taxonomy. Track intent-revealing events only. You can always add more later.
Mistake 2: Not Identifying Users
If you don't identify users, you can't track their journey. You'll see pageviews but not conversions.
Fix: Call posthog.identify() immediately after signup or login. Make it non-negotiable.
Mistake 3: Ignoring Data Quality
Test data, bot traffic, and your own usage will pollute your analytics. You'll make decisions based on lies.
Fix: Filter out your own IP address and test accounts. In PostHog, go to Project Settings → Data Management and add filters.
Mistake 4: Capturing Sensitive Data
Don't send passwords, payment tokens, or PII to PostHog (or any analytics platform). It's a security risk and violates privacy laws.
Fix: Only send what you need. Use IDs, not names. Use plan names, not credit card numbers.
Mistake 5: Not Connecting to Your Backend
Frontend-only tracking is fragile. Ad blockers block it. Users close their browsers. Critical events get lost.
Fix: Capture critical events (signups, payments, churn) from your backend. The frontend can capture engagement events.
Advanced: PostHog for SEO-Driven Products
If you're a founder who ships and relies on organic traffic, PostHog becomes even more valuable.
Here's why: organic traffic is your cheapest traffic, but it's also the hardest to understand. Someone lands on your blog from Google, reads an article, and either converts or leaves. PostHog shows you exactly what happens in between.
Track Organic Conversion Paths
- Set up Google Search Console integration so you know which keywords drive traffic.
- In PostHog, create a segment: "Users from organic search."
- Track their behavior: Do they read your docs? Do they sign up? Do they convert to paid?
- Identify the highest-converting keywords and content pieces.
- Double down on what works.
For this, you'll want to also implement GA4 events for SEO tracking so you see which content drives engagement.
Measure Content Performance
Not all blog posts are equal. Some drive signups. Some drive nothing.
- Add a custom event:
blog_post_viewedwith propertypost_slug. - Track which blog posts lead to feature usage or signups.
- Use this to guide your content strategy.
Optimize Your Onboarding for Organic Users
Organic users are self-serve. They don't have a sales call. Your onboarding has to be perfect.
- Track
onboarding_startedandonboarding_completed. - Watch sessions from organic users who didn't complete onboarding.
- Find the friction point.
- Fix it.
- Measure the improvement.
This is where PostHog becomes a content and SEO tool, not just a product tool.
The PostHog Setup Checklist
Before you call this done, run through this checklist:
- PostHog account created and project set up
- API key stored in environment variables
- SDK installed and deployed to production
- Events are flowing into PostHog (verified in Activity → Events)
- Custom events defined and implemented (signup, feature usage, payment, etc.)
- Users are being identified after signup
- Dashboard created with core KPIs
- Test data and your own traffic filtered out
- Session recording enabled (if desired)
- Webhooks set up for critical events
- Weekly review habit established
Conclusion: Ship Analytics, Not Guesses
PostHog setup takes 30 minutes. The payoff is infinite.
You now have visibility into what users actually do. You can answer questions that matter: "Why aren't users converting?" "Which features drive retention?" "What's our churn rate?" You're no longer guessing. You're shipping based on data.
The next steps:
- This week: Get PostHog running and watch the events flow in.
- Next week: Implement your event taxonomy and identify users.
- Week 3: Build your dashboard and run your first analysis.
- Week 4+: Review weekly and ship based on what you learn.
If you're serious about organic growth alongside product metrics, also set up the free SEO tool stack every founder should deploy so you can track how organic traffic feeds into your product funnel. Add Google Tag Manager for event tracking if you want cross-domain tracking, and use Lighthouse audits to ensure your site's performance doesn't kill your conversion rate.
The founders who win are the ones who see clearly. PostHog gives you that clarity. Install it today. Start shipping smarter tomorrow.
For a complete walkthrough with video, check out the 9-step PostHog setup framework or the PostHog review for solo SaaS founders which includes a 15-minute Next.js setup guide.
You've got this. Ship it.
Get the next one on Sunday.
One short email a week. What is working in SEO right now. Unsubscribe in one click.
Subscribe on Substack →