Build Plausible
YESreplaces $9/mosaves $108/yrback to the verdict
Privacy-first analytics for your own sites: a tracker under 2 KB with no cookies, an ingest endpoint that never stores a raw IP, a daily-rotating visitor hash exactly as Plausible defines it, sessions and bounce rate computed at write time, and a fast dashboard. Honest at personal-site scale, and you can state the ceiling.
Before step 1
Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.
- installfree
Why Everything in this build runs on it: the server, the scripts, the tests.
Get it Download the LTS installer from nodejs.org, or install with your package manager (brew install node, or nvm install 22). Restart the terminal afterwards. open ↗
Verify
node --version prints v22 or higher - installfree
Why Every step below is a command you type or a file you edit.
Get it VS Code (code.visualstudio.com), Cursor or Zed. Open a folder for the project and use the editor's built-in terminal. open ↗
Verify
You can open a folder and run a command in its terminal - installfree
Why History for your code, and the way most hosts deploy.
Get it Install from git-scm.com or with your package manager, then run git init in the project folder once it exists. open ↗
Verify
git --version prints a version - have readyfree
Why The tracker is a script tag you add to each site; you need somewhere to add it.
Get it Write down each site's domain. Each becomes a site_id in SITES.
- API keyfree
Why Country breakdowns need an IP-to-country database. GeoLite2 is free but requires an account to download and to receive updates.
Get it Sign up at maxmind.com/en/geolite2/signup, then Account > Manage License Keys > Generate new license key. Download GeoLite2-Country.mmdb (or use geoipupdate). Put the file path in .env. open ↗
Verify
The .mmdb file exists at GEOIP_DB_PATH - decidefree
Why The privacy claim rests on one rule: the salt rotates daily and the old one is deleted. If you keep old salts, this is a tracker with extra steps.
Get it Read Plausible's data policy page once before Phase 1 so the design is yours, not a guess. open ↗
- accountabout $5 a month
Why This needs one process running all the time with a public address. Sites post to it from the visitor's browser, so it must be public.
Get it Hetzner Cloud (from about 4 EUR), DigitalOcean or Fly.io. Ubuntu 24.04, the smallest size. You need SSH access and a public IP. Only needed for the deploy phase; develop locally first. open ↗
- accountroughly $10 a year, or free on an existing domain
Why The collector needs an HTTPS address, e.g. stats.yourdomain.com.
Get it Register at Cloudflare Registrar, Porkbun or Namecheap, or use a subdomain of one you already own. You add one DNS record in the deploy phase. open ↗
- installfree
Why Automatic HTTPS in front of the Node process. Without TLS the browser features this relies on (and your visitors' trust) do not work.
Get it On the VPS: follow the install steps at caddyserver.com/docs/install for Ubuntu. One Caddyfile with your domain and a reverse_proxy line is the whole config. open ↗
Verify
caddy version prints a version on the server
Data model
Create these before the first phase that stores anything. Changing a table later is the expensive kind of change.
- `events`: id, site_id, name ('pageview' | custom), path, referrer_host,
screen_class ('mobile' | 'tablet' | 'desktop'), country, browser, os,
visitor_hash, session_id, timestamp
- `sessions`: id, site_id, visitor_hash, started_at, last_event_at, entry_path,
exit_path, event_count, is_bounce
- `salts`: day (date), salt, created_at
Index `events(site_id, timestamp)` and `events(site_id, path, timestamp)`.
Never store a raw IP address or a raw user-agent string in any table. Not in a
column you plan to drop later, not in a log file. This is the one rule that makes
the product what it claims to be.Environment variables
These go in a .env file the app reads at startup. The pack's .env.example is this table as a file · copy it, never commit the filled-in version.
| Variable | Needed | Example | Where the value comes from |
|---|---|---|---|
PORT | required | 3000 | Any free port; Caddy proxies to it. |
DATABASE_PATH | required | ./data/analytics.db | SQLite file. Back it up. |
SITES | required | yoursite.com,blog.yoursite.com | Comma-separated site ids accepted by the ingest endpoint. Anything else is dropped. |
GEOIP_DB_PATH | optional | ./data/GeoLite2-Country.mmdb | The MaxMind file from the prerequisites. |
RETENTION_DAYS | optional | 400 | Raw events older than this are rolled up and deleted nightly. |
ADMIN_USER | required | admin | Any username for the basic-auth admin pages. |
ADMIN_PASSsecret | required | change-me-to-a-long-random-string | Generate one: openssl rand -base64 24. Never reuse a real password. |
SITE_URL | required | https://stats.yourdomain.com | Public base URL of the collector, used in the snippet. |
The build, in order
Identity without cookies
The visitor hash and its salt, done exactly right, before anything else exists.
salts (day, salt, created_at). Generate 32 random bytes per UTC day on first use.
Files
server.mjsidentity.mjsterminalmkdir analytics && cd analytics && git init && npm init -y && npm pkg set type=module mkdir data public && cp .env.example .env
sha256(daily_salt + site_domain + ip + user_agent). Include the domain so the same visitor on two of your sites is two hashes. The ip and user agent exist only inside this function.
At UTC midnight create tomorrow's salt and delete yesterday's row. Deleting is what makes cross-day re-identification impossible even for you.
done when · tick each as it passesIngest endpoint
POST /api/event stores derived facts only and never makes a visitor's page wait.
events (id, site_id, name, path, referrer_host, screen_class, country, browser, os, visitor_hash, session_id, timestamp). Index (site_id, timestamp) and (site_id, path, timestamp).
Screen class from a width the tracker sends, browser and os from the user agent, country from the GeoLite2 lookup. Strip query strings and hashes from path. Then drop the inputs.
Unknown site ids are accepted and dropped. Malformed bodies get 202 too. Cap the body at 2 KB. An analytics endpoint must leak nothing about itself.
done when · tick each as it passesThe tracker
Under 2 KB, no cookies, counts SPA route changes once, honours opt-out.
On load send a pageview with path, referrer and innerWidth via navigator.sendBeacon with a fetch fallback. Hook pushState and popstate for SPA routes. Expose window.plausible-style track(name) for custom events.
If either is set, send nothing at all.
p.v1.js; bump on change.
- terminal
<script defer data-site="yoursite.com" src="https://stats.yourdomain.com/p.v1.js"></script>
done when · tick each as it passesSessions and bounce rate
Sessionize at write time so the dashboard never does it.
sessions (id, site_id, visitor_hash, started_at, last_event_at, entry_path, exit_path, event_count, is_bounce).
If the visitor's last event on this site was under 30 minutes ago, update that session; otherwise open a new one. A session with one pageview is a bounce.
done when · tick each as it passesBot filtering
Drop obvious bots at ingest and count what you dropped.
A short bot list, plus events with no referrer and a zero width.
filtered (day, site_id, reason, n). A traffic drop you can explain beats one you guess at.
done when · tick each as it passesDashboard
Every panel one indexed query; every number reconcilable with SQL.
Unique visitors, pageviews, bounce rate and visit duration for today, 7 and 30 days.
Each a GROUP BY with a LIMIT.
No chart library. Dark mode.
- terminal
node scripts/seed.mjs 100000
done when · tick each as it passesRetention and deploy
Old events rolled up, live on your domain, documented with the ceiling stated.
daily (day, site_id, visitors, pageviews, bounces) computed from events, then delete events older than RETENTION_DAYS. Charts read daily for old ranges.
Files
deploy/analytics.serviceCaddyfileThe snippet, a plain-language policy (collected, derived, never stored, salt deleted daily), and the traffic ceiling as a number.
Files
README.mdPRIVACY.md
done when · tick each as it passesOperate it like a productproduct builder
Only for the product-builder path: know when the collector is down, never lose the database, and keep the server patched.
Answer 200 with the build id and a quick database read. Point a free uptime monitor (or your own, from the Healthchecks entry on this site) at it so an outage is noticed before a user notices.
One JSON line per request: method, path, status, duration, no raw IPs. Rotate weekly with logrotate, keep eight.
SQLite's .backup command makes a consistent copy while the app runs. Copy it to object storage or a second machine; then, once, restore it into a fresh checkout and confirm the app reads it.
terminalsqlite3 data/app.db ".backup '/tmp/app-$(date +%F).db'" rclone copy /tmp/app-$(date +%F).db remote:backups/
Firewall allowing only 22, 80 and 443; unattended security updates on; the app running as an unprivileged user under systemd with Restart=on-failure.
done when · tick each as it passes
That is the whole plan for Plausible. What it deliberately does not cover is below · check the gaps before you call it a replacement.
- Funnels, goals, revenue attribution and scheduled email reports.
- Bot filtering tuned on adversarial traffic. Yours is a list.
- Millions of pageviews. SQLite on one box is honest for personal sites; above that, self-host Plausible.
- battle-tested bot filtering
- fast queries at millions of pageviews
- email reports, funnels, goal tracking
- GDPR homework done for you
- A public shareable dashboard link per site
- Goal tracking as a custom event with a conversion panel
Need the files? The project pack on the verdict page hands your agent the whole brief · more analytics.