Waggle

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.

Install by hand
Free and open source on GitHub, MIT license
The Waggle console: 4.6k people today across six sites, with hourly visits, the leading site and where visits came from.
The same console on a phone.

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…

60°1 cellwaggle · 5 columns, 19 cellsOpacity 12–100%Corner, 16% of the side162432

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.

Today, hour by hour
Today’s visits hour by hour, with yesterday drawn behind them for comparison.
Hourly visits with a tooltip and yesterday’s line dotted.
Ask AI
Ask about your numbers in plain words. Workers AI answers, inside your own account.

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.

5.7kvisits today · by site
example.com2.3k
blog.example.com1.3k
shop.example.net628
Ask a follow-up…
Countries
Cloudflare already knows which country each visit comes from, so Waggle uses that. IP addresses are never stored.
CountriesLast 7 days
United States12k34%
United Kingdom4.4k12%
Germany4.0k11%
France2.5k7%
Map
Every country that sent visits in the range you picked. Pick one under Countries to see its visits.
A dot map of the world with countries lit.
Referrers and pages
Where your visitors came from, including utm_source tags, and which pages they read most.
ReferrersLast 7 days
Direct / unknown15k42%
Google6.2k17%
Hacker News5.2k14%
newsletter (utm)2.6k7%
PagesLast 7 days
/6.9k12%
/blog/launch-notes3.7k7%
/pricing2.8k5%
/docs/setup2.4k4%
Adding a site
A new site shows the snippet to paste and a button to test it.
studio.example.com is waiting for its first visitTest received 20:04

Add this line to every page, just before </head>.

<script defer src="https://collector.example.com/w.js"></script>Copy
Open siteSend a test visit

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

Your Cloudflare accountYour sitesA 2.4 KB snippetYouIn any browserpage viewCollector WorkerThe door for page viewsWrite-only, drops botsAnalytics EngineOne row per page viewConsole WorkerReads with SQLCloudflare AccessThe door for youOnly who you allowWorkers KVSettings, a salt a dayWorkers AIOnly with Ask onEverything in the box runs on Cloudflare, in your accountone rowSQL
Why a collector of its ownA page view is decided in one place: bots and link previews are dropped, your own network is left out of the numbers, visits are told apart from page views, and people are counted with the daily hash. It also means the site can be hosted anywhere, not only behind Cloudflare.
What it uses from CloudflareWorkers to run the collector and the console, Analytics Engine to store one row per page view and query it with SQL, KV for settings and salts, Access for the login, and Workers AI for Ask. It does not read Cloudflare Web Analytics or your zone’s traffic analytics.

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

How it compares

QuestionWaggleCloudflare Web AnalyticsPlausibleGoogle Analytics
PriceFreeFreePaidFree
CookiesNoneNoneNoneYes
SampledOnly at very high trafficOnly on large queriesOnly above 10M page viewsIn some reports
Bots and your own visitsLeft out, link previews too—Bots left outKnown bots left out
Where the data livesYour Cloudflare accountCloudflare’s dashboardEU servers, or your ownGoogle
Source codeOpen, MIT licenseClosedOpen, AGPL licenseClosed

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.

View on GitHub

3m 44s · My test run: Codex, on a new Cloudflare account.

With your coding agent

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.

Prompt
Install Waggle from github.com/marele/waggle for my sites. Clone it into ~/waggle and follow its AGENTS.md.
By hand

You’ll need Node 22.12 or newer, Git and a Cloudflare account. The free plan is enough.

Terminal
cd ~
git clone https://github.com/marele/waggle
cd waggle && npm ci
npm run setup