Open-source analytics for Cloudflare Workers
I host all my sites on Cloudflare Workers, so I built analytics that run there too. It uses no cookies, it’s open source, and it lives in your own Cloudflare account.
Free and open source on GitHub, MIT license

The backstory
I built it for my own sites
I run 6–7 sites and apps. I rebuilt them myself and moved them off the various platforms they lived on. Along the way I stumbled upon Cloudflare Workers, which turned out to be a great place to host them. (not sponsored btw)
Slowly I found it does a lot more than hosting. Analytics, for one. But the numbers are sampled, and I wanted one place to see all my sites.
So I hacked something together over a weekend.
Then I thought it might help other people who host on Workers too. So I cleaned it up, refactored it and made it open source. That’s Waggle.
waggle/ˈwaɡ(ə)l/ · noun
the dance a honeybee does to tell the hive where the flowers are.
Yeah, I know, I used to be more fun at parties…
What the console shows
Some of the highlights
See people, visits and page views for each of your sites, for today, the last 7, 30 or 90 days, or any month.

Why is example.com ahead today?
5683 visits landed so far today, and example.com took the most with 2311 (41%), ahead of blog.example.com with 1278.
Add this line to every page, just before </head>.
<script defer src="https://collector.example.com/w.js"></script>CopyUnder the hood
How it runs on Cloudflare
Waggle is two Workers, one Analytics Engine dataset and two KV namespaces, all in your own account. Setup creates them for you.
The code
How it works, in code
A few real excerpts from the code, lightly trimmed.
// one page view, nothing else var body = JSON.stringify({ h: location.hostname, p: path().slice(0, 300), // the page r: r.slice(0, 253), // the referrer n: n, // how the tab got here u: utm_source, m: touch ? 1 : 0 }); fetch(api, { method: "POST", body, keepalive: true, credentials: "omit", referrerPolicy: "no-referrer" });w.js
export async function person(env, ip, ua, site, day) { const s = await salt(env, day); if (!s) return ""; const h = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${s}|${ip}|${ua}|${site}`)); return [...new Uint8Array(h).slice(0, 12)] .map((b) => b.toString(16).padStart(2, "0")).join(""); }salt.js
env.HITS.writeDataPoint(row({ site, path: cleanPath(d.p), // ids and tokens stripped ref, country: req.cf?.country, device: device(ua), browser: browser(ua), visit, person: who, utm, day, }));index.js
SELECT site, day, COUNT(*) AS views, SUM(visit = '1') AS visits, COUNT(DISTINCT person) AS people FROM waggle WHERE day BETWEEN $dfrom AND $dto GROUP BY site, dayquery.js
How it compares
| Question | Waggle | Cloudflare Web Analytics | Plausible | Google Analytics |
|---|---|---|---|---|
| Price | Free | Free | Paid | Free |
| Cookies | None | None | None | Yes |
| Sampled | Only at very high traffic | Only on large queries | Only above 10M page views | In some reports |
| Bots and your own visits | Left out, link previews too | — | Bots left out | Known bots left out |
| Where the data lives | Your Cloudflare account | Cloudflare’s dashboard | EU servers, or your own | |
| Source code | Open, MIT license | Closed | Open, AGPL license | Closed |
There are plenty of other good tools out there. These are just the ones I know.
How to install
I’m a designer, not a developer. So setup had to be easy. Paste one prompt and a coding agent does it for you. Like to tinker? Install it by hand instead.
3m 44s · My test run: Codex, on a new Cloudflare account.
Works with Claude Code, Codex or any agent that can run a terminal. In Claude Code you can also add the Waggle plugin and run /waggle:setup.
Install Waggle from github.com/marele/waggle for my sites. Clone it into ~/waggle and follow its AGENTS.md.
You’ll need Node 22.12 or newer, Git and a Cloudflare account. The free plan is enough.
cd ~ git clone https://github.com/marele/waggle cd waggle && npm ci npm run setup
