12 KiB
Umami — Self-Hosted Web Analytics
Device Type: Docker Containers (hosted on NAS16) Containers: umami, umami_db Hostname / URL: stats.cutthecard.net IP Address: 192.168.150.40 (shares NAS16's host IP), host port 3001 VLAN: 50 — Lab / Servers
Last Updated: 2026-10-02
🧩 Role & Purpose
Umami is the self-hosted, cookie-free web analytics service for CutTheCard and other KingDezigns sites. It answers: which pages people open, how long they stay, where they come from, whether they scroll/read articles, and which content they favor.
Why Umami (decision record, 2026-10-01):
- Not Google Analytics — CutTheCard handles financial data and trades on privacy; GA would put a third party's script on the site, force Privacy Statement changes and likely a consent banner, and contradicts the self-hosted philosophy used elsewhere (DNS, Git, proxy, stock API).
- Not Plausible Community Edition — needs ClickHouse as well as Postgres; too heavy for a Raspberry Pi already running Forgejo, Fund Tracker (x2), CutTheCard (x2) and Apache.
- Umami — one app container plus a Postgres 16 container (same pattern as Fund Tracker/CutTheCard), official ARM64 image (confirmed working on NAS16), no cookies, data stays on KingDezigns hardware.
- Google Search Console (no script on the site) is still recommended alongside it for search-query data.
🌐 Public Access
- Domain:
https://stats.cutthecard.net/ - Proxy: NPM on HAS (192.168.150.30) →
192.168.150.40:3001(schemehttp) - NPM settings: Let's Encrypt cert, Force SSL + HTTP/2 on, Websockets off (not needed), Block Common Exploits on
- Public DNS: Dreamhost A record, kept current by the DDNS script on NAS16 (
/usr/scripts/ddns/ddns_update.sh—stats.cutthecard.netwas added to its subdomain list) - Pi-hole local DNS:
stats.cutthecard.net→192.168.150.30(avoids the NAT-hairpin failure; after editing Pi-hole v6 records usedocker restart pihole, notreloaddns) - Tracker script URL:
https://stats.cutthecard.net/insights(renamed from the defaultscript.jsviaTRACKER_SCRIPT_NAME=insights, so generic ad-block lists are less likely to match)
CrowdSec/Fail2Ban need no changes — traffic proxied through NPM inherits protection like every other service. No firewall changes were required (existing NPM → NAS16 inbound path).
🐳 Docker Configuration
Project
OMV → Services → Compose, project/file name umami, at /Kingdezignsnas16/umami/ (root-only directory; use sudo bash -c "cd ... && ...").
| Item | Value |
|---|---|
| Compose file | /Kingdezignsnas16/umami/umami.yml (OMV-managed, symlinked as compose.yml) |
| Database data | /opt/umami/pgdata — owned 70:70 (postgres alpine UID/GID), mode 700 |
| Secrets file | /opt/umami/umami.secrets — outside OMV's control, root:root, mode 600 |
| App image | ghcr.io/umami-software/umami:postgresql-latest (ARM64 confirmed working) |
| DB image | postgres:16-alpine |
| Host port | 3001 → container 3000 (3000 on NAS16 is Forgejo) |
| Network | umami_default (created by compose) |
Compose file (no secrets in it)
services:
umami_db:
image: postgres:16-alpine
container_name: umami_db
restart: unless-stopped
env_file:
- /opt/umami/umami.secrets
environment:
- POSTGRES_DB=umami
- POSTGRES_USER=umami
volumes:
- /opt/umami/pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U umami -d umami"]
interval: 10s
timeout: 5s
retries: 5
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
container_name: umami
restart: unless-stopped
depends_on:
umami_db:
condition: service_healthy
ports:
- "3001:3000"
env_file:
- /opt/umami/umami.secrets
environment:
- DISABLE_TELEMETRY=1
- TRACKER_SCRIPT_NAME=insights
Secrets file — variable names only (values live in Vaultwarden and in the file itself)
POSTGRES_PASSWORD=<secret>
DATABASE_URL=postgresql://umami:<same password>@umami_db:5432/umami
APP_SECRET=<secret>
Generate values with openssl rand -hex 24 (hex avoids URL-encoding problems in DATABASE_URL). Never write real values into documentation. Changing the Postgres password after the database is initialized requires changing it inside Postgres too (the env var only applies on first init).
Why env_file and not the OMV Environment box (lesson learned 2026-10-01)
- OMV regenerates
umami.envfrom its own stored settings on every apply (the file carries a "do not edit, changes will be lost" header). Values typed into the file by hand are wiped, and the UI Environment box did not populate it in this setup. Compose therefore saw blank${UMAMI_DB_PASSWORD}and Postgres refused to start (Database is uninitialized and superuser password is not specified). - Putting
UMAMI_DB_PASSWORD=...in a service'senvironment:list does not fix${...}substitution — interpolation reads the project.env, not service environments. - Fix: external
env_file(above). Values go directly to each container, nothing depends onumami.env, and nothing is lost when OMV re-saves the project. - Apply changes with down then up (not
docker restart), which recreates containers with the new environment.
Key commands
# Start / recreate
sudo bash -c "cd /Kingdezignsnas16/umami && docker compose down && docker compose up -d"
# Status / logs
sudo docker ps | grep umami
sudo docker logs umami --tail 30
sudo docker logs umami_db --tail 20
# Local health
curl -I http://192.168.150.40:3001 # expect 200
# Update images (both are real registry images, so pull is safe)
sudo bash -c "cd /Kingdezignsnas16/umami && docker compose pull && docker compose up -d"
📊 Websites Configured in Umami
| Website | Domain(s) | Notes |
|---|---|---|
| CutTheCard | cutthecard.net, www.cutthecard.net |
Tracked via /dashboard/site-scripts.js (below). Website ID is embedded in that file; IDs are not secrets (visible in page source). |
| kingdezigns.com (personal site) | kingdezigns.com, www.kingdezigns.com |
Separate Umami website with its own ID; tag added directly to that site's HTML, optionally with a copy of reading-tracker.js. |
Optional: a third website "CutTheCard QA" (its ID pasted into the debt.qa.cutthecard.net entry in site-scripts.js) would allow testing in QA without polluting production data. Not created yet.
🔌 How CutTheCard Loads Tracking
Full detail is in server_debteliminator.md §12h. Summary:
- Every public/app page carries one tag:
<script defer src="/dashboard/site-scripts.js?v=1"></script>. site-scripts.jsis the single registry of site-wide scripts. It loads Umami (page views, duration, referrers) and, on pages containing an<article>,reading-tracker.js.- Custom events from
reading-tracker.js:scroll-depth(25/50/75/100),engaged-time(30/60/120/180 s of active time),article-read(≥75% depth + ≥45 s active). - CTA clicks can be tracked with
data-umami-event="..."attributes on links — no JavaScript needed. - Guards: admin area never tracked; only production hostnames report; Do Not Track and Global Privacy Control honored; Stripe-return pages have query/hash stripped; no
identify()and no user data in event properties.
🔐 Security & Privacy
- Default login is
admin/umami— it must be changed on first login (Settings → Profile), with the new password stored in Vaultwarden. Umami has no built-in 2FA or lockout; use a long random password. - Tracking is cookie-free and first-party. Inside the logged-in app it is page-level only (no user identity, no financial data).
- The Privacy Statement should disclose the analytics (see open items); legal wording should be reviewed, and publishing a new version triggers the re-acceptance gate for all users.
- Your own visits can be excluded per browser per site:
localStorage.setItem('umami.disabled', 1)on that site's origin.
💾 Backup
- Data to protect:
/opt/umami/pgdataand/opt/umami/umami.secrets. - Use
pg_dump, not a raw copy of a live Postgres directory:sudo docker exec umami_db pg_dump -U umami umami | gzip > /tmp/umami-$(date +%Y%m%d).sql.gz - Status (2026-10-02): not yet folded into
/usr/scripts/omv/nas16-backup.sh— see open items.
🛠️ Troubleshooting & Gotchas
| Symptom | Cause / Fix |
|---|---|
umami_db unhealthy, log says superuser password not specified |
Secrets not reaching the container — see "Why env_file" above. |
WARN The "UMAMI_DB_PASSWORD" variable is not set |
Compose still using ${...} from an empty umami.env; use the env_file version of the compose file. |
| Chrome prompt "kingdezigns.com wants to access other devices on your local network" | Chrome Local Network Access. On the LAN, Pi-hole resolves stats.cutthecard.net to a private IP, and a public site loading a script from a private address triggers the prompt. Affects only the admin's own LAN browsers; real visitors resolve the public IP. Click Allow (remembered per site). |
| Tracker never sends data | Script src must be https:// (an http:// URL is blocked as mixed content on HTTPS pages); data-domains must be plain text matching the page's hostname (a copied markdown-link artifact like [www.x.com](https://www.x.com) breaks it); check umami.disabled in localStorage. |
dig: command not found on NAS16 |
Not installed; use getent hosts stats.cutthecard.net or sudo apt install dnsutils. |
| Pageviews appear but no Events | Events fire only on pages containing an <article> (blog posts and the six Learning Center guides), after scrolling/active time; confirm reading-tracker.js returns 200 in production; use Umami → Realtime to watch live. |
apply_site_scripts.py crashes with PermissionError on main.py |
The project directory is root-only; run the script with sudo (a dry run needs it too). |
⏳ Open Items (2026-10-02)
- Verify custom events in production — page views confirmed recording;
scroll-depth/engaged-time/article-readnot yet confirmed visible in Events (tracker logic passed simulated testing; check production file availability and test on a single article page). - Confirm the default
adminpassword was changed and stored in Vaultwarden. - Add
/opt/umami/pgdata(viapg_dump) and/opt/umami/umami.secretstonas16-backup.sh. - Update the Privacy Statement to disclose first-party, cookie-free analytics (including page-level tracking inside the app); legal review; bundle with another legal version bump if possible.
- Optional: create a QA website in Umami and paste its ID into
site-scripts.js. - Tag the in-flight external demo page(s) if they should be tracked (
apply_site_scripts.pyaccepts extra page paths). - Consider CTA click events (
data-umami-event) for planner/signup funnel measurement.
🧠 Summary for AI Systems
- Umami = self-hosted, cookie-free analytics on NAS16 (VLAN 50): containers
umami(port 3001→3000) andumami_db(Postgres 16), OMV Compose projectumamiat/Kingdezignsnas16/umami/, public URLhttps://stats.cutthecard.netvia NPM on HAS (Force SSL). Tracker script path is/insights. - Secrets are in
/opt/umami/umami.secrets(outside OMV) viaenv_file— OMV regeneratesumami.envand wipes manual edits;${VAR}interpolation does not read serviceenvironment:entries. Never document secret values. - Chosen over Google Analytics (privacy/trust/self-hosting philosophy) and Plausible CE (ClickHouse too heavy for the Pi).
- CutTheCard loads tracking through one loader (
/dashboard/site-scripts.js); future scripts are added there only. Seeserver_debteliminator.md§12h. - Two Umami websites: CutTheCard and the personal kingdezigns.com site.
- Pi-hole override
stats.cutthecard.net → 192.168.150.30; DDNS script updated; the Chrome Local Network Access prompt on LAN-side public sites is expected and harmless. - Default login must be changed; backup is not yet in
nas16-backup.sh; custom reading events were not yet confirmed at time of writing.