TL;DR: A SaaS analytics stack has three layers: product analytics (PostHog, Amplitude), business analytics (Stripe, ChartMogul), and web analytics (Plausible, Cloudflare Web Analytics). This guide covers the tool selection, event tracking architecture with TanStack Start, and a metrics dashboard setup.
Introduction
You can't improve what you don't measure. For SaaS, that means understanding user behavior (product analytics), revenue trends (business analytics), and acquisition channels (web analytics). The challenge is choosing tools that work together without creating data silos.
The ideal stack is privacy-first, cost-effective for early stage, and exportable to your own database.
Three-Layer Analytics Architecture
| Layer | Tool | Monthly Cost | Key Metrics |
|---|---|---|---|
| Web Analytics | Plausible | $10-20 | Pageviews, bounce rate, referrals |
| Product Analytics | PostHog (self-host) | $0-100 | Events, funnels, retention |
| Business Analytics | ChartMogul + Stripe | $50-100 | MRR, ARR, LTV, churn |
| Custom Warehouse | D1 or ClickHouse | In-house | All events, custom queries |
Event Tracking Setup
import posthog from 'posthog-js'
// Track signup event
posthog.capture('user_signed_up', {
plan: 'pro',
referral_source: 'organic',
company_size: '1-5',
})
// Feature usage tracking
posthog.capture('feature_used', {
feature: 'analytics_export',
user_id: user.id,
})
Metrics Dashboard with TanStack Table
function MetricsDashboard() {
const { data } = useQuery({
queryKey: ['metrics', 'monthly'],
queryFn: () => fetchMonthlyMetricsFn({ data: { months: 12 } }),
})
return (
<div className="grid grid-cols-4 gap-4">
<MetricCard label="MRR" value={data.mrr} prefix="$" />
<MetricCard label="ARR" value={data.arr} prefix="$" />
<MetricCard label="Net New MRR" value={data.netNewMrr} prefix="$" />
<MetricCard label="Logo Count" value={data.logoCount} />
<MetricCard label="NRR" value={data.nrr} suffix="%" />
<MetricCard label="Gross Churn" value={data.grossChurn} suffix="%" />
</div>
)
}
Conclusion
A three-layer analytics stack gives you complete visibility into your SaaS. Start with free tiers and upgrade as you grow. The key is consistent event naming and a data export strategy so you own your data. For deeper dives, explore our SaaS Monitoring and Observability Guide and the PostHog setup reference.