ABC Books visitor counts and funnels: seeing where people stop, with self-hosted Umami (rebuild guide) 15NOV2026

Anonymous page and lesson-step counts for all of abcbooks.fyi, and funnel reports from the welcome page to a finished lesson

Posted on 15th Nov 2026

abcbooks.fyi (the welcome page, family accounts, the readers and the math) now counts visits anonymously with Umami, the same self-hosted analytics the blog uses. It also marks each step a visitor takes, so a funnel report shows how many people get from the first page to a finished lesson and where the rest stop. This post is the complete rebuild guide. Every block has a Copy button.

How it works

  1. Every page on abcbooks.fyi loads one small file, /account/stats.js (served by CT 308 (abc-account), the family-account service).
  2. stats.js loads Umami’s tracker from https://abcbooks.fyi/stats/script.js. That’s the same site, not the analytics domain. The edge Caddy, CT 108 (Caddy reverse proxy), passes just two paths, /stats/script.js and /stats/api/send, on to Umami in CT 203 (umami). Same-site matters because the Fire kids browser and the ABC Books Fire app only open approved sites. Passing only those two paths means the Umami login page isn’t reachable through abcbooks.fyi.
  3. On load, Umami counts a normal page view (/, /account/, /readers/, /math/, /privacy.html).
  4. The apps are single pages, so the address never changes while a child moves through a lesson. Each important moment calls abcStats.step('/readers/lesson', { book, lesson }). That records a page view at a made-up address, which funnels can use, plus an event of the same name with the book, lesson and step as details.
  5. Umami stores each hit within about a second. The funnel reports (saved in Umami) count how many visitors reached each step, in order, within 2 hours.

What is recorded: the page or step, book id, lesson number, stars, and Umami’s usual referrer, browser, OS, device, screen size, language and country/region. What is never sent: reader names, emails, anything typed, drawings or recordings. Umami sets no cookies and doesn’t store the internet address. The privacy page was updated to say exactly this before the tracking went live. It’s also the privacy policy of the Amazon Appstore listing, which used to promise “no analytics”.

Only abcbooks.fyi counts. The copy at games.503mail.com/abcbooks/, which the family’s kids use on their tablets, is deliberately left out, so home use doesn’t skew the numbers.

The steps

  • Readers (ABC Books, app.js): /readers/added (new reader name added), /readers/picked (reader tapped), /readers/book, /readers/lesson, /readers/step/<words|spell|listen|read|talk|print|script|board>, /readers/done.
  • Math (Ray’s Arithmetic, app.js): /math/added, /math/picked, /math/book, /math/lesson, /math/step/<step>, /math/done.
  • Paywall (sync.js): /readers/paywall, /math/paywall when a child reaches a locked lesson.
  • Account (account.js): /account/code-sent, /account/signed-in, /account/learner-added, /account/checkout (with the plan), /account/paid.
  • Welcome page buttons (data-umami-event): “Welcome: try readers”, “Welcome: try math”, “Welcome: create account”.

The funnel reports

  • Readers: start to finish: /readers/ → book → lesson → listen → read → print → done.
  • Math: start to finish: /math/ → book → lesson → done.
  • Sign-up to paid: / → /account/ → code sent → signed in → checkout → paid.

Containers involved

Container Role LAN IP
CT 108 (Caddy reverse proxy) edge for abcbooks.fyi; new /stats/ route x.x.0.122
CT 203 (umami) Umami analytics (Docker, port 3002), dashboard at analytics.503mail.com x.x.0.156
CT 202 (creator-signup) holds the Umami admin login the scripts read (never typed into a script) DHCP
CT 306 (abc-web) serves the readers, the math and privacy.html x.x.0.127
CT 308 (abc-account) serves the welcome page, account pages, sync.js and the new stats.js DHCP

Where to run each command

  • Proxmox host shell: in the Proxmox web UI click pve → Shell (or SSH to the host as root).
  • Your PC: PowerShell, in the folder that holds the project folders (ABCAccounts, ABCBooks, RaysArithmetic).

Rebuild, step by step

This assumes ABC Books, Ray’s Arithmetic and the family accounts are already rebuilt (their guides: ABC Books app, Ray’s Arithmetic, family accounts). Those posts embed the current app.js, index.html, sync.js, account.js and pages, with the tracking lines already in them. It also assumes Umami is running in CT 203 (umami), as in the creator platform build.

1. Make a working folder on the host

Proxmox host shell:

mkdir -p /root/abc-stats && cd /root/abc-stats

2. Create the files

Paste each block into the Proxmox host shell.

host_umami_site.sh: creates the Umami website abcbooks.fyi and a public share link, and prints both ids. It reads the admin login from CT 202 (creator-signup).

cat > /root/abc-stats/host_umami_site.sh <<'EOF'
#!/bin/bash
# Run on the Proxmox host: creates the Umami website "abcbooks.fyi" (Umami = CT 203) if
# missing, plus a share link, and prints its id. The admin login is read from the
# creator-signup app on CT 202 (where it already lives), never typed here.
set -eu
U=http://$(pct exec 203 -- hostname -I | awk '{print $1}'):3002
F=/opt/creator-signup/signup_handler.py
USR=$(pct exec 202 -- grep -oP '^UMAMI_ADMIN_USER = "\K[^"]+' $F)
PW=$(pct exec 202 -- grep -oP '^UMAMI_ADMIN_PASS = "\K[^"]+' $F)
TOK=$(jq -n --arg u "$USR" --arg p "$PW" '{username:$u,password:$p}' \
      | curl -fs -H 'Content-Type: application/json' -d @- $U/api/auth/login | jq -r .token)
H="Authorization: Bearer $TOK"
ID=$(curl -fs -H "$H" "$U/api/websites?pageSize=200" | jq -r '.data[] | select(.domain=="abcbooks.fyi") | .id' | head -1)
if [ -z "$ID" ]; then
  ID=$(curl -fs -H "$H" -H 'Content-Type: application/json' -X POST $U/api/websites \
       -d '{"name":"abcbooks.fyi","domain":"abcbooks.fyi"}' | jq -r .id)
  SHARE=$(head -c 12 /dev/urandom | base64 | tr -d '/+=')
  curl -fs -H "$H" -H 'Content-Type: application/json' -X POST $U/api/websites/$ID \
       -d "{\"name\":\"abcbooks.fyi\",\"domain\":\"abcbooks.fyi\",\"shareId\":\"$SHARE\"}" >/dev/null
fi
curl -fs -H "$H" $U/api/websites/$ID | jq -r '"website_id \(.id)\nshare_id \(.shareId)"'
EOF

add-stats-route.py: adds the two /stats/ paths to the abcbooks.fyi block of CT 108’s Caddyfile, just above its catch-all handle {. It keeps a backup and runs only once.

cat > /root/abc-stats/add-stats-route.py <<'EOF'
# Adds anonymous visit counting to the abcbooks.fyi block of CT 108's Caddyfile:
#   /stats/script.js and /stats/api/send -> Umami (CT 203). Same origin, so the Fire kids
#   browser and the Fire app allow it; only these two paths, so the Umami login is not exposed.
# usage (on CT 108): python3 add-stats-route.py /etc/caddy/Caddyfile <Umami address>
# Keeps the original as <Caddyfile>.bak-stats. Added once (marker /stats/script.js).
import re, shutil, sys

path, umami = sys.argv[1], sys.argv[2]
lines = open(path).read().split('\n')
start = next((i for i, l in enumerate(lines) if re.match(r'^abcbooks\.fyi\s*\{', l)), None)
if start is None:
    sys.exit('no abcbooks.fyi block in the Caddyfile')
end = next(i for i in range(start + 1, len(lines)) if lines[i].startswith('}'))
if any('/stats/script.js' in l for l in lines[start:end]):
    sys.exit('ok, already there')
shutil.copy(path, path + '.bak-stats')
part = ['# anonymous visit counts (Umami, CT 203): only the script and the collector',
        'handle /stats/script.js {', '\trewrite * /script.js', '\treverse_proxy ' + umami + ':3002', '}',
        'handle /stats/api/send {', '\trewrite * /api/send', '\treverse_proxy ' + umami + ':3002', '}']
cands = [i for i in range(start + 1, end) if re.match(r'^(\s+)handle\s*\{\s*$', lines[i])]
if not cands:
    sys.exit('no catch-all "handle {" in the abcbooks.fyi block')
at = cands[-1]
ind = re.match(r'^(\s+)', lines[at]).group(1)
lines[at:at] = [ind + l for l in part]
open(path, 'w').write('\n'.join(lines))
print('ok, added %d lines' % len(part))
EOF

host-stats.sh: copies the route script into CT 108, runs it, validates the Caddyfile, and reloads Caddy. If validation fails it puts the old file back.

cat > /root/abc-stats/host-stats.sh <<'EOF'
#!/bin/bash
# Run on the Proxmox host (after copying add-stats-route.py next to it): adds the /stats/ route
# to the edge Caddy (CT 108), validates, reloads, and rolls back if validation fails.
set -eu
cd "$(dirname "$0")"
UMAMI=$(pct exec 203 -- hostname -I | awk '{print $1}')
pct push 108 add-stats-route.py /root/add-stats-route.py
pct exec 108 -- python3 /root/add-stats-route.py /etc/caddy/Caddyfile "$UMAMI"
if pct exec 108 -- caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile; then
  pct exec 108 -- systemctl reload caddy
  echo reloaded
else
  pct exec 108 -- cp /etc/caddy/Caddyfile.bak-stats /etc/caddy/Caddyfile
  echo 'validation failed, restored the old Caddyfile'; exit 1
fi
EOF

stats.js: the loader every page includes. Put the website id from step 3 into ID. This copy goes into ABCAccounts/static/ on your PC.

cat > /root/abc-stats/stats.js <<'EOF'
// Anonymous visit counts for abcbooks.fyi: self-hosted Umami (CT 203) through /stats/ on the same site,
// so it also works in the Fire kids browser and the Fire app. No cookies; never sends names, emails or
// anything typed. Pages load this with <script src="/account/stats.js"></script> (before their own script).
//   abcStats.step('/readers/book', { book: 'primer1881' })  -> a page view at that address (for the funnel)
//                                                              + an event of the same name with the details
//   abcStats.event('Code sent')                             -> an event only
// Only counts on abcbooks.fyi itself (not games.503mail.com/abcbooks/, where the family plays, or local previews).
(function () {
  var ID = '4e011ec3-f91b-4666-9593-4ed2563a408f';
  var q = [], on = location.hostname === 'abcbooks.fyi';
  function ready() { return window.umami && typeof window.umami.track === 'function'; }
  function send(a) {
    try {
      if (a.url) window.umami.track(function (p) { p.url = a.url; p.title = a.url; return p; });
      if (a.name) window.umami.track(a.name, a.data);
    } catch (e) {}
  }
  function push(a) { if (!on) return; if (ready()) send(a); else if (q.length < 50) q.push(a); }
  window.abcStats = {
    step: function (url, data) { push({ url: url, name: data ? url : null, data: data }); },
    event: function (name, data) { push({ name: name, data: data }); }
  };
  if (!on) return;
  var s = document.createElement('script');
  s.defer = true; s.src = '/stats/script.js';
  s.setAttribute('data-website-id', ID);
  s.onload = function () { while (q.length) send(q.shift()); };
  document.head.appendChild(s);
})();
EOF

host_umami_funnels.sh: saves the three funnel reports in Umami (replacing old ones with the same name) and prints each funnel as plain text.

cat > /root/abc-stats/host_umami_funnels.sh <<'EOF'
#!/bin/bash
# Run on the Proxmox host: saves the abcbooks.fyi funnel reports in Umami (CT 203), replacing ones with the
# same name, then prints each funnel for the last 30 days (DAYS=7 bash ... for another span). Step addresses come from /account/stats.js callers:
# ABCBooks app.js (/readers/...), RaysArithmetic app.js (/math/...), ABCAccounts account.js (/account/...).
set -eu
WEB=4e011ec3-f91b-4666-9593-4ed2563a408f
U=http://$(pct exec 203 -- hostname -I | awk '{print $1}'):3002
F=/opt/creator-signup/signup_handler.py
USR=$(pct exec 202 -- grep -oP '^UMAMI_ADMIN_USER = "\K[^"]+' $F)
PW=$(pct exec 202 -- grep -oP '^UMAMI_ADMIN_PASS = "\K[^"]+' $F)
TOK=$(jq -n --arg u "$USR" --arg p "$PW" '{username:$u,password:$p}' \
      | curl -fs -H 'Content-Type: application/json' -d @- $U/api/auth/login | jq -r .token)
H="Authorization: Bearer $TOK"
steps() { jq -nc '$ARGS.positional | map({type:"path", value:.})' --args "$@"; }
END=$(date +%s); START=$(( END - ${DAYS:-30} * 86400 ))
EXISTING=$(curl -fs -H "$H" "$U/api/reports?websiteId=$WEB&pageSize=100")
save() {   # name, steps json
  for id in $(echo "$EXISTING" | jq -r --arg n "$1" '.data[]? | select(.name==$n) | .id'); do
    curl -fs -H "$H" -X DELETE "$U/api/reports/$id" >/dev/null
  done
  jq -nc --arg w $WEB --arg n "$1" --argjson s "$2" \
     '{websiteId:$w, type:"funnel", name:$n, description:"abcbooks.fyi funnel (see ABCAccounts/README.md)", parameters:{steps:$s, window:120}}' \
    | curl -fs -H "$H" -H 'Content-Type: application/json' -d @- $U/api/reports | jq -r '"saved \(.name) \(.id)"'
  echo "last ${DAYS:-30} days:"
  jq -nc --arg w $WEB --argjson s "$2" --argjson a $START --argjson b $END \
     '{websiteId:$w, type:"funnel", parameters:{steps:$s, window:120, startDate:($a|todate), endDate:($b|todate)}, filters:{}}' \
    | curl -s -H "$H" -H 'Content-Type: application/json' -d @- $U/api/reports/funnel | jq -r '.[]? | "  \(.value): \(.visitors) visitors (\(.dropped) dropped)"' || true
}
save "Readers: start to finish" "$(steps /readers/ /readers/book /readers/lesson /readers/step/listen /readers/step/read /readers/step/print /readers/done)"
save "Math: start to finish"    "$(steps /math/ /math/book /math/lesson /math/done)"
save "Sign-up to paid"          "$(steps / /account/ /account/code-sent /account/signed-in /account/checkout /account/paid)"
EOF

3. Create the Umami website

Proxmox host shell. Note the website_id it prints. It goes into stats.js (ID) and host_umami_funnels.sh (WEB).

bash /root/abc-stats/host_umami_site.sh

4. Add the edge route

Proxmox host shell. It should end with Valid configuration and reloaded.

bash /root/abc-stats/host-stats.sh

Check from anywhere. You should get 200 for the script and 404 for the Umami login:

curl -s -o /dev/null -w "%{http_code}\n" https://abcbooks.fyi/stats/script.js
curl -s -o /dev/null -w "%{http_code}\n" https://abcbooks.fyi/stats/login

5. The page and app changes

These are already in the current project files, so the deploy scripts send them. For reference:

  • Each page has <script src="/account/stats.js"></script> just before its own script: welcome.html, account.html (ABCAccounts), index.html and privacy.html (ABCBooks), index.html (RaysArithmetic). On the app pages it comes before /account/sync.js.
  • Each app has one helper near its top, and calls it at the moments listed above:
const track = (url, data) => { try { window.abcStats && window.abcStats.step(url, data); } catch (e) {} };
  • Bump SHELL in both apps’ sw.js so tablets pick up the new files: ABC Books went to abc-shell-v58, Ray’s to rays-shell-v21.

6. Deploy

Your PC, one at a time:

powershell -ExecutionPolicy Bypass -File ABCAccounts\tools\deploy.ps1
powershell -ExecutionPolicy Bypass -File ABCBooks\deploy.ps1
powershell -ExecutionPolicy Bypass -File RaysArithmetic\deploy.ps1

7. Save the funnels and read them

Proxmox host shell. DAYS is how far back to look (default 30):

DAYS=30 bash /root/abc-stats/host_umami_funnels.sh

The output is plain text, one line per step, for example:

saved Readers: start to finish 18ab633c-...
last 1 days:
  /readers/: 1 visitors (0 dropped)
  /readers/book: 1 visitors (0 dropped)
  /readers/lesson: 1 visitors (0 dropped)
  /readers/step/listen: 0 visitors (1 dropped)

“Dropped” is how many visitors who reached the step above stopped before this one. You can also open the reports in the Umami dashboard (analytics.503mail.com → Reports). The public overview, with no login, is the website’s share link (share_id from step 3), at https://analytics.unlock-now.me/share/<share_id>.

Troubleshooting: where the logs are

Is the browser sending hits?

  • Where: the browser’s developer tools on any abcbooks.fyi page → Network, filter stats.
  • Look for: GET /stats/script.js 200, then POST /stats/api/send 200 on each page and step. A 404 on /account/stats.js means CT 308 doesn’t have the file (redeploy ABCAccounts). No /stats/ requests at all on a page other than abcbooks.fyi is correct, because counting is off there. Typing abcStats in the console should show an object.

Edge Caddy (CT 108 (Caddy reverse proxy))

  • Where: the Caddy journal in CT 108.
  • Open: Proxmox host shell.
pct exec 108 -- journalctl -u caddy -n 50 --no-pager
  • Look for: dial tcp ...:3002: connect: connection refused means Umami is down. A failed reload prints the Caddyfile line number. The backup from step 4 is /etc/caddy/Caddyfile.bak-stats. “certificate maintenance” lines are normal noise.

Umami (CT 203 (umami))

  • Where: the Umami Docker container’s log.
  • Open: Proxmox host shell.
pct exec 203 -- sh -c 'docker logs --tail 50 $(docker ps -q --filter ancestor=ghcr.io/umami-software/umami:postgresql-latest)'
  • Look for: Ready on start. Database errors (P1001 and similar) mean the Postgres container is down. Each hit isn’t logged, so a quiet log is normal.

Quick health check

Proxmox host shell:

pct exec 203 -- curl -s http://127.0.0.1:3002/api/heartbeat

{"ok":true} means Umami is up.

Notes

  • The privacy promise comes first. The privacy page is also the Appstore listing’s policy. Any new field that gets recorded has to be described there before it goes live. Never pass a reader name or an email to abcStats.
  • Funnel steps are page addresses, not events. Umami funnels match one path or one event per step. That’s why every step is also sent as a page view at a fixed address like /readers/step/read, and the book and lesson ride along as event details.
  • Some steps are optional. “New words” is skipped when a lesson has no new words, “Talk about it” exists only in the Fourth Reader, and “Spell it” only in Spell & Read. So the saved readers funnel uses listen → read → print, which every lesson has.
  • A slip during this build: a sed insert into account.js reported nothing in my check (I grepped for track(, but the declaration is const track = (), so I added the helper a second time. const declared twice is a syntax error, and the account page was broken for about a minute. A quick check that runs every changed file through new Function(source) in the browser caught it. Do that after any hand edit to these scripts.
  • Umami’s funnel API wants ISO dates (2026-11-15T10:00:00Z) for startDate/endDate. Epoch milliseconds passed through jq’s todate give a date thousands of years out, and the report comes back empty.
  • The first test visit (mine, adding a reader called “Tester” and starting Primer lesson 1) is 1 visitor in the data from 15 Nov 2026.