Cloudflare Worker / server-side analytics with Dataflare: setup in two minutes

Workers, Hono apps and other server code send events with a plain fetch to your Dataflare Worker. Use this for events that only the server knows about, such as a payment succeeding.

Dataflare is open-source analytics that runs in your own Cloudflare account: web analytics, product analytics (trends, funnels, retention), session replay, feature flags and A/B tests. There is no Dataflare service to sign up for. Your events go to a Worker and a D1 database in your account.

1. Deploy Dataflare

From your project's root, with a Cloudflare API token:

CLOUDFLARE_API_TOKEN=… npx dataflare-cli init

dataflare init detects Cloudflare Worker / server-side from your package.json, creates the database, the replay bucket and the Worker, and prints the snippet below with your real host and project filled in. It also writes AGENTS.md, a Claude Code skill and .mcp.json, so your coding agent can do the next steps for you.

2. Add the snippet

In any server code:

// Server-side capture: POST events to Dataflare.
await fetch('https://glass.<you>.workers.dev/e', {
  method: 'POST',
  body: JSON.stringify({ project: 'my-app', events: [{ id: crypto.randomUUID(), event: 'order_paid', ts: Date.now(), distinct_id: userId, user_id: userId, props: { amount: 42 } }] }),
});

Send one event per action. Events with an id are de-duplicated, so retries are safe.

3. Track what matters

await fetch(GLASS_HOST + '/e', { method: 'POST', body: JSON.stringify({ project: GLASS_PROJECT, events: [{ id: crypto.randomUUID(), event: "signup_completed", ts: Date.now(), distinct_id: userId, user_id: userId, props: {"plan":"pro"} }] }) });

Name events object_action in the past tense (signup_completed, invite_sent) and put details in properties, never personal data.

4. Check it works

npx dataflare-cli status
npx dataflare-cli events signup_completed

Then open https://glass.<you>.workers.dev/app (sign in with npx dataflare-cli key), or ask your agent: "Which traffic source converts best to signup?"

Serve it from your own domain

Ad blockers often block third-party analytics domains. Serve Dataflare from a path on your own site instead, if your domain is on Cloudflare:

npx dataflare-cli init --route example.com

Then use https://example.com/_glass as the host in the snippet.

Next