Migrating from Microsoft Clarity to PostHog: The Self-Hosting Reality
Microsoft Clarity is free, dead simple, and gives you heatmaps and session recordings without touching your wallet. So why would anyone migrate to PostHog, especially the self-hosted version that requires actual DevOps work?
The answer isn't "because PostHog is better." It's "because your needs changed."
Clarity works brilliantly when you need basic session replay and heatmaps. But the moment you want to answer questions like "what's the conversion rate for users who clicked the pricing page twice in one session" or "which feature flag cohort has better retention," you're stuck. Clarity doesn't do product analytics, feature flags, A/B testing, or data exports that you control.
PostHog does all of that. And if you self-host it, you own every byte of user data. No third-party processors, no data residency questions, no wondering if Microsoft is training models on your user behavior.
But self-hosting isn't a shortcut. Let's talk about what actually happens.
Why Teams Actually Make This Move
In three years of building custom software for SMBs, we've seen this migration happen for four specific reasons:
1. Compliance and data sovereignty Your client is a European healthcare provider, or you're handling financial data in Singapore. Sending session recordings to Microsoft's servers — even anonymized — creates compliance headaches. Self-hosted PostHog means your data never leaves your infrastructure.
2. You outgrew session replay Clarity shows you what users do. PostHog shows you what they do, why it matters, and lets you experiment to change it. You get funnels, retention curves, cohort analysis, and SQL access to raw events. That's the difference between a replay tool and a product analytics platform.
3. Engineering wants one source of truth If you're already running Metabase or Grafana, pulling PostHog data into your warehouse makes sense. Clarity's data is locked in their dashboard. PostHog lets you export everything to ClickHouse, Postgres, or S3. Our AI agents that handle data pipeline work see this pattern constantly — teams want analytics that integrates with their stack, not another silo.
4. Feature flags and experimentation PostHog bundles session replay with feature flags and A/B testing. If you're shipping fast — especially in a custom CRM or ERP where different clients need different features — having flags in the same tool as your analytics eliminates context switching. Check out how we use this in products like HotelDesk and EventPro.
The Self-Hosting Math: What It Actually Costs
PostHog Cloud is free up to 1 million events per month. Self-hosting costs whatever your infrastructure costs. Here's the reality:
Minimum viable setup:
- 4 vCPU, 8GB RAM instance (ClickHouse + PostHog app + Redis)
- 100GB SSD storage
- You'll pay $40-80/month on AWS, DigitalOcean, or Hetzner
- Add $10-15/month for backups and monitoring
So roughly $50-100/month, but you're doing the work. Installing PostHog is a Docker Compose file or a Helm chart. Maintaining it means:
- Upgrading PostHog every 4-6 weeks (they ship fast)
- Monitoring ClickHouse disk usage (events pile up)
- Managing SSL certs, firewalls, and CORS configs
- Debugging when session recordings don't load (usually a CDN or proxy issue)
If you have a DevOps person on retainer or an engineering team that owns infrastructure, this is manageable. If you're a 3-person startup where everyone wears six hats, you're better off on PostHog Cloud until you hit their paid tier.
When self-hosting saves money: PostHog Cloud charges per event after the free tier. If you're tracking 10 million events/month, you're paying $450/month. At that scale, self-hosting on a $200/month instance makes sense — you're paying for compute, not per-event fees.
The Migration Process: What to Expect
Migrating from Clarity to PostHog isn't a one-click operation. Here's the actual checklist:
1. Data mapping and event planning
Clarity auto-captures everything. PostHog also auto-captures, but you'll want to define custom events for product-specific actions. Sit down and list:
- Which user actions matter (button clicks, form submissions, feature usage)
- What properties you need (user role, subscription tier, device type)
- Which funnels you'll analyze (signup flow, checkout, feature adoption)
This takes 2-4 hours. Don't skip it. Bad event design means useless analytics.
2. Deploy PostHog
For self-hosted, follow their Docker Compose guide. You'll:
- Spin up the instance
- Configure your domain and SSL (Let's Encrypt works fine)
- Set environment variables (secret keys, database URLs, object storage for recordings)
- Test session replay and event ingestion with a staging app
Budget a day for this if you know Docker. Two days if you're learning as you go.
3. Instrument your frontend
Replace Clarity's script tag with PostHog's SDK. For a basic React app:
import posthog from 'posthog-js'
posthog.init('YOUR_PROJECT_API_KEY', {
api_host: 'https://posthog.yoursite.com',
capture_pageview: true,
capture_pageleave: true
})
Session replay requires enabling it in PostHog's settings. Auto-capture works out of the box. Custom events look like:
posthog.capture('pricing_clicked', {
plan: 'enterprise',
source: 'navbar'
})
If you're running multiple apps — say a customer-facing SaaS and an internal admin panel — you'll need to set up distinct projects or use separate API keys.
4. Parallel run (recommended)
Keep Clarity running for 2-4 weeks while PostHog collects data. Compare session volumes, event counts, and any custom metrics you care about. This catches configuration issues before you cut over completely.
5. Team training
PostHog's interface is more complex than Clarity's. Your non-technical stakeholders will need a walkthrough of:
- Creating insights (charts, funnels, retention graphs)
- Watching session replays
- Setting up dashboards
Budget 1-2 hours for a training session. Record it.
Common Gotchas and How to Fix Them
Session recordings not loading Usually a CORS issue. Check your PostHog instance's allowed origins. If you're behind a reverse proxy (Nginx, Cloudflare), verify WebSocket passthrough is enabled.
ClickHouse disk fills up fast PostHog stores raw events in ClickHouse. By default, it keeps everything. Set retention policies in PostHog settings (e.g., delete events older than 90 days). Monitor disk usage weekly.
Sampling confusion PostHog samples session recordings by default (20-50% depending on your plan). You can increase this to 100%, but storage costs spike. Most teams sample at 30% and manually trigger full recording for specific users.
GDPR and data anonymization
PostHog respects Do Not Track headers if you enable it. For GDPR, you'll need to:
- Disable IP capturing (on by default)
- Set up a cookie consent banner
- Implement a
/privacy/deleteendpoint that calls PostHog's user deletion API
If you're building custom CRMs or ERPs (check our services for examples), your clients will ask about this. Have the answer ready.
When to Stay on Clarity
You don't need PostHog if:
- Session replay and heatmaps are enough
- You're not doing product experimentation
- Your traffic is under 100K sessions/month
- You don't have compliance constraints
- Your team doesn't have DevOps capacity
Clarity is a fantastic tool. It's free, fast, and maintained by Microsoft. Use it until it doesn't solve your problem anymore.
The Bottom Line
Migrating from Clarity to self-hosted PostHog makes sense when you need product analytics, feature flags, and data ownership. It doesn't make sense as a like-for-like replacement.
Expect to spend 3-5 days on the migration (setup, instrumentation, testing). Expect $50-200/month in hosting costs. Expect ongoing maintenance.
The payoff is control. You own the data, you set the retention, you integrate with your stack. For teams shipping fast — especially in custom software where every client has different needs — that control is worth the operational overhead.
If you're evaluating this for a custom CRM, ERP, or AI-powered product, we've done this migration for clients in hospitality, legal, and healthcare. The patterns repeat. The gotchas are predictable. Happy to talk through your specific setup — hit us up.