Build Plausible

YESreplaces $9/mosaves $108/yrback to the verdict

0%0 of 30 items done

Saved on this device only. Tick prerequisites first, then work the phases in order · do not start one until the checks above it pass.

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.

estimated effort weekendthe files for this build are in the project pack

RuntimeNode 22, node:http and node:sqliteDatabaseSQLite in WAL modeTrackerHand-written vanilla JS under 2 KBGeoMaxMind GeoLite2 country database, read locallyHostingA small VPS behind Caddy

Before step 1

Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.

  1. 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

  2. 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

  3. 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

  4. 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.

  5. 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

  6. 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 ↗

  7. about $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 ↗

  8. roughly $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 ↗

  9. 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.

VariableNeededExampleWhere the value comes from
PORTrequired3000Any free port; Caddy proxies to it.
DATABASE_PATHrequired./data/analytics.dbSQLite file. Back it up.
SITESrequiredyoursite.com,blog.yoursite.comComma-separated site ids accepted by the ingest endpoint. Anything else is dropped.
GEOIP_DB_PATHoptional./data/GeoLite2-Country.mmdbThe MaxMind file from the prerequisites.
RETENTION_DAYSoptional400Raw events older than this are rolled up and deleted nightly.
ADMIN_USERrequiredadminAny username for the basic-auth admin pages.
ADMIN_PASSsecretrequiredchange-me-to-a-long-random-stringGenerate one: openssl rand -base64 24. Never reuse a real password.
SITE_URLrequiredhttps://stats.yourdomain.comPublic base URL of the collector, used in the snippet.

The build, in order

  1. Identity without cookies

    The visitor hash and its salt, done exactly right, before anything else exists.

    1. salts (day, salt, created_at). Generate 32 random bytes per UTC day on first use.

      Files server.mjsidentity.mjs

      terminal
      mkdir analytics && cd analytics && git init && npm init -y && npm pkg set type=module
      mkdir data public && cp .env.example .env
    2. 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.

    3. 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 passes
  2. Ingest endpoint

    POST /api/event stores derived facts only and never makes a visitor's page wait.

    1. 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).

    2. 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.

    3. 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 passes
  3. The tracker

    Under 2 KB, no cookies, counts SPA route changes once, honours opt-out.

    1. 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.

    2. If either is set, send nothing at all.

    3. p.v1.js; bump on change.

    4. terminal
      <script defer data-site="yoursite.com" src="https://stats.yourdomain.com/p.v1.js"></script>
    done when · tick each as it passes
  4. Sessions and bounce rate

    Sessionize at write time so the dashboard never does it.

    1. sessions (id, site_id, visitor_hash, started_at, last_event_at, entry_path, exit_path, event_count, is_bounce).

    2. 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 passes
  5. Bot filtering

    Drop obvious bots at ingest and count what you dropped.

    1. A short bot list, plus events with no referrer and a zero width.

    2. filtered (day, site_id, reason, n). A traffic drop you can explain beats one you guess at.

    done when · tick each as it passes
  6. Dashboard

    Every panel one indexed query; every number reconcilable with SQL.

    1. Unique visitors, pageviews, bounce rate and visit duration for today, 7 and 30 days.

    2. Each a GROUP BY with a LIMIT.

    3. No chart library. Dark mode.

    4. terminal
      node scripts/seed.mjs 100000
    done when · tick each as it passes
  7. Retention and deploy

    Old events rolled up, live on your domain, documented with the ceiling stated.

    1. daily (day, site_id, visitors, pageviews, bounces) computed from events, then delete events older than RETENTION_DAYS. Charts read daily for old ranges.

    2. Files deploy/analytics.serviceCaddyfile

    3. The 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 passes
what this build does not replace
after v1, if you want it

Need the files? The project pack on the verdict page hands your agent the whole brief · more analytics.