Count the page load, not only the script
A script counts only when a browser runs it. The edge collector counts the HTML response itself, so blocked and no-JS visits still show up.
How it works
You put a one-file Cloudflare Worker in front of your site, or add a middleware to your Vercel or Next.js project. It passes every request to your origin as before. For each HTML page it serves, it sends one small beacon to the collector after the response has gone out (with ctx.waitUntil), so your visitors don’t wait for it.
The beacon carries the path, the user agent, the country header your CDN already adds, and a request ID. It doesn’t carry the IP address, and nothing touches the visitor’s device.
Deduplication, and where it falls short
Most visitors will be counted twice: once by the edge and once by the script. The edge collector adds a request ID to the page, and the script sends it back. When both arrive for the same site, path and short time window, the script hit wins and the edge hit is marked as a duplicate.
- A visitor whose script is blocked is counted once, by the edge, and marked
source=edgeso you can see how many there are. - Cached pages served by a CDN without passing through the Worker are not seen by the edge. Put the Worker on the route that serves the HTML.
- Edge hits know less: no screen width, and the referrer only if the browser sent one.
- Crawlers are recognised by user agent and go to the AI report, not to your visitor numbers.
Install
On Cloudflare it’s a single Worker file you deploy in front of your origin. On Vercel or Next.js it’s a few lines in your middleware. The quickstart has both in full.
import { nextCollector } from './edge-collector/next';
const collect = nextCollector({ siteId, edgeKey, endpoint });
export function middleware(req: Request, event: { waitUntil(p: Promise<unknown>): void }) {
collect(req, event);
}
Not on npm yet: copy the collector files into your project. Options may change before launch.
Count the visitors you’ve been missing.
30-day free trial, no card needed. Create an account with your work email and add your first site.