Introduction
diy-analytics is a self-hosted web analytics platform. You deploy it, you own the database, and no visitor data ever leaves your infrastructure.
It answers the questions most teams reach for a third-party analytics tool for:
- How many people are visiting my site, right now and over time?
- Which pages, sources, and campaigns drive the most traffic?
- Where are visitors coming from, and what device are they on?
- Are visitors completing the goals and funnels that matter to my business?
Who it's for
- Bloggers and content creators who want to know what resonates without sending readers' data to a third party.
- Small businesses that want real insight without a per-visitor subscription fee.
- Indie developers adding analytics to a side project in minutes, not days.
- Teams with a privacy mandate — GDPR/CCPA-sensitive products, internal tools, or anything where a third-party tracker is a non-starter.
Why diy-analytics
- You own the data. Everything lives in your own PostgreSQL database — not a vendor's servers.
- No cookies, no PII. The tracker doesn't set cookies or collect personal data, so it operates under GDPR and CCPA without a consent banner.
- Focused feature set. Pages, sources, devices, goals, funnels, retention, and alerts — the metrics that drive decisions, without the bloat.
- MIT-licensed, free. The only cost is hosting and database, both of which have generous free tiers.
- Fast by default. The tracking script is under 2 KB and loads with
async/defer, so it never blocks page render.
How it works
diy-analytics has three moving pieces:
- Your dashboard instance — a Next.js app you deploy (to Vercel or anywhere Node.js runs), backed by a PostgreSQL database. Projects, settings, and all collected analytics live here.
- The tracking snippet — a single
<script>tag, unique per project, added to the<head>of the site you're measuring. See Connecting Your Website. - The tracker endpoint —
/api/tracker.js, served by your own deployment, which records pageviews, sessions, custom events, and Web Vitals into your database.
At no point does data leave your infrastructure — it's your server talking to your database.
Tech stack
- Framework: Next.js (App Router)
- Database & ORM: PostgreSQL & Drizzle ORM
- Styling: Tailwind CSS
- Testing: Jest
Project status
diy-analytics is in alpha. The core dashboard — traffic analytics, goals, funnels, retention, alerts, and the tracking script — is fully functional and used day to day. Version 0.1.1 migrated the database engine from MongoDB to PostgreSQL via Drizzle ORM; if you're upgrading an existing deployment, see Migrating from MongoDB.
Where to go next
Getting Started
Provision a PostgreSQL database and deploy your instance to Vercel in minutes.
Connecting Your Website
Register a project and drop the tracking snippet into your site's head.
Dashboard Features
A tour of every panel: metrics, funnels, retention, goals, and alerts.
Migrating from MongoDB
Step-by-step guide to migrate existing MongoDB data to PostgreSQL.