Analytics for Cloudflare
Cloudflare Workers give you the most reliable ad-blocker bypass for analytics. A single Worker script proxies BetterMeter through your domain at the edge — sub-millisecond overhead, global distribution, and completely invisible to blockers.
Worker proxy script
Deploy this Worker to your Cloudflare zone. It intercepts requests to /bm/* and forwards all three BetterMeter paths — the tracker script, the event endpoint and the noscript pixel — preserving headers and the query string. Because the request originates from your domain, ad blockers never trigger.
const PROXY = {
"/bm/s": "https://bettermeter.com/api/s",
"/bm/e": "https://bettermeter.com/api/e",
"/bm/p": "https://bettermeter.com/api/p",
};
export default {
async fetch(request) {
const url = new URL(request.url);
const target = PROXY[url.pathname];
if (!target) {
return fetch(request);
}
const upstream = new URL(target);
upstream.search = url.search;
return fetch(upstream, {
method: request.method,
headers: request.headers,
body: request.method === "GET" || request.method === "HEAD" ? undefined : request.body,
});
},
};The Worker only carries the requests; the snippet decides where events go. data-api must name the proxied event path. Without it the tracker takes its endpoint from the script's own origin and posts to /api/e on your domain — a path the Worker never matches — so the script loads and every event is dropped.
<script defer data-site="your-domain.com" data-api="/bm/e" src="/bm/s"></script>
<img src="/bm/p?s=your-domain.com" alt="" style="position:absolute;width:0;height:0;overflow:hidden" />Route configuration
name = "bettermeter-proxy"
main = "worker.js"
compatibility_date = "2024-01-01"
[[routes]]
pattern = "your-domain.com/bm/*"
zone_name = "your-domain.com"BetterMeter vs Cloudflare Web Analytics
- 01AI traffic attribution — BetterMeter identifies visits from ChatGPT, Claude, and Perplexity. Cloudflare Web Analytics groups these as generic referrers.
- 02Bot & crawler breakdown — See every bot by name, frequency, and pages crawled. Cloudflare only shows aggregate bot counts.
- 03CLI, MCP & API tracking — BetterMeter tracks your entire product, not just web pages served through Cloudflare.
- 04Real-time dashboard — See visitors as they arrive. Cloudflare Web Analytics has a delay of several minutes.