# Dataflare > Open-source, agent-first analytics that runs in your own Cloudflare account: web analytics, product analytics (trends, funnels, retention), session replay with text transcripts, feature flags and A/B tests. Installed with one command and queried through MCP, a CLI or HTTP. ## Install (for coding agents) 1. In the user's project, run `npx dataflare-cli init`. It needs a Cloudflare API token, from the `CLOUDFLARE_API_TOKEN` environment variable or the `--token` flag. In non-interactive shells, also pass `--account ` when the token can see several accounts. - Optional flags: `--project `, `--eu` (EU data jurisdiction), `--lake` (Iceberg storage for high volume), `--route example.com` (first-party serving at /_glass), `--dry-run`. - Token permissions: Account › Workers Scripts › Edit; Account › D1 › Edit; Account › Workers R2 Storage › Edit; Account › Account Settings › Read. 2. `dataflare init` prints the install snippet for the detected framework. Add it to the site's , for example: `` For npm apps: `npm i dataflare-web`, then `import { glass } from 'dataflare-web'` and `glass.init({ host, project })`. 3. Track key events: `glass.capture('signup_completed', { plan: 'pro' })`; after login `glass.identify(user.id, { plan })`. Name events object_action in snake_case past tense. Put details in properties, never personal data. 4. Verify: `npx dataflare-cli status`, then `npx dataflare-cli events signup_completed` after triggering the event. 5. Document every custom event before building funnels or trends on it. Call MCP `define_event` (or `npx dataflare-cli events --describe "…"`) with: - a description of how and when the event is fired (which user action or code path), and - a meaning for each property (what it is, and which values to expect). On an existing project, start with `list_events` and clear the `undocumented` list first. `dataflare init` also writes AGENTS.md instructions, a Claude Code skill (.claude/skills/glass/SKILL.md) and an MCP server entry in .mcp.json (`npx dataflare-cli mcp`). ## Query - MCP tools: overview, query_web, query_trends, query_funnel, query_retention, sql, list_events, describe_event, define_event, mark_event, query_sources, site_health, usage_and_cost, property_values, list_person_properties, instrument, search_persons, get_person, list_cohorts, save_cohort, count_cohort, delete_cohort, list_replays, summarise_replay, replay_snapshot, analyse_replays, annotate_replay, delete_replay_note, list_flags, save_flag, delete_flag, list_experiments, create_experiment, experiment_results, update_experiment, list_projects, create_project. - CLI: `npx dataflare-cli query web --from -7d`, `npx dataflare-cli query funnel --steps '$pageview,signup_completed'`, `npx dataflare-cli sql "SELECT …"`, `npx dataflare-cli --help`. - HTTP: `GET /api` lists every endpoint; `GET /llms.txt` on a deployment has its real URLs. - Upgrades: `GET /health` (and `overview`) report `upgradeAvailable` when a newer release exists. Tell the user to run `npx dataflare-cli@latest upgrade`; do not upgrade yourself. ## Docs - [Getting started](https://dataflare.dev/docs/getting-started.md): Install, frameworks, custom domains, EU data, upgrading. - [Browser SDK](https://dataflare.dev/docs/sdk.md): init, capture, identify, flags, replay and consent. - [Agents: MCP, CLI and HTTP](https://dataflare.dev/docs/agents.md): Every MCP tool, CLI command and API endpoint, with recipes. - [Queries](https://dataflare.dev/docs/queries.md): Properties, filters, time ranges, every query type and SQL. - [Flags and experiments](https://dataflare.dev/docs/experiments.md): Flags, assignment, and how results are computed. - [Privacy](https://dataflare.dev/docs/privacy.md): What's stored, cookieless mode, deletion, EU data. - [Architecture](https://dataflare.dev/docs/architecture.md): Request paths, identity, portable SQL, packages. - [The lake store (beta)](https://dataflare.dev/docs/lake.md): Iceberg tables on R2 for high volume. - [Extending Dataflare](https://dataflare.dev/docs/extending.md): Add a query type, MCP tool, storage engine or framework. - [All docs in one file](https://dataflare.dev/llms-full.txt) ## Guides - [Next.js](https://dataflare.dev/guides/nextjs.md): Add analytics to a Next.js app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Astro](https://dataflare.dev/guides/astro.md): Add analytics to a Astro app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [SvelteKit](https://dataflare.dev/guides/sveltekit.md): Add analytics to a SvelteKit app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Nuxt](https://dataflare.dev/guides/nuxt.md): Add analytics to a Nuxt app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Remix / React Router](https://dataflare.dev/guides/remix.md): Add analytics to a Remix / React Router app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Vite](https://dataflare.dev/guides/vite.md): Add analytics to a Vite app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Plain HTML](https://dataflare.dev/guides/html.md): Add analytics to a Plain HTML app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [Cloudflare Worker / server-side](https://dataflare.dev/guides/cloudflare-workers.md): Add analytics to a Cloudflare Worker / server-side app with Dataflare: open-source web and product analytics, session replay and A/B tests that run in your own Cloudflare account. Step-by-step setup. - [With your coding agent](https://dataflare.dev/guides/coding-agents.md): Let your coding agent install analytics, track events and answer questions about your users. Dataflare writes agent instructions and an MCP server config at install. - [Cookieless analytics](https://dataflare.dev/guides/cookieless-analytics.md): How Dataflare counts visitors without cookies or local storage: a daily-rotating salted hash in your own Cloudflare Worker. What works, what needs consent, and how to switch. - [Replays agents can read](https://dataflare.dev/guides/session-replay-for-agents.md): Dataflare session replay comes with a text transcript of every session: pages, clicks with CSS selectors, rage and dead clicks, errors with stack frames and failed requests. Agents read it through MCP. - [A/B tests on Cloudflare](https://dataflare.dev/guides/ab-testing-cloudflare.md): Run feature flags and A/B tests from your own Cloudflare Worker with Dataflare: server-side evaluation, targeting rules, Bayesian results and sample-ratio checks. - [Self-hosted without servers](https://dataflare.dev/guides/self-hosted-analytics-without-servers.md): Self-host analytics with no servers, Docker or database to manage: Dataflare is a Cloudflare Worker, a D1 database and an R2 bucket in your own account, deployed with one command and upgraded from CI. ## Compare - [Dataflare vs PostHog](https://dataflare.dev/vs/posthog/): PostHog is the closest product to Dataflare and does far more: surveys, a data warehouse, error tracking, mobile SDKs and a hosted cloud with a team behind it. Choose Dataflare if you want the core of that (web and product analytics, replay, flags and experiments) running in your own Cloudflare account, with no vendor, no usage-based bill and an agent that can query it from the first minute. - [Dataflare vs Google Analytics](https://dataflare.dev/vs/google-analytics/): Google Analytics is free, everywhere, and the right tool if you buy Google Ads and want conversions to flow into them. Choose Dataflare if you'd rather not send visitor data to Google, want a dashboard you can read without training, need session replay or A/B tests, or want your coding agent to answer questions about your traffic. - [Dataflare vs Plausible](https://dataflare.dev/vs/plausible/): Plausible is a lovely, focused product: one page of web stats, hosted in the EU, with nothing to run. Choose Dataflare if you've outgrown web stats and need product analytics (funnels, retention, people), session replay or experiments, or if you'd rather keep the data in your own Cloudflare account than pay a subscription. - [Dataflare vs Amplitude](https://dataflare.dev/vs/amplitude/): Amplitude is the reference for behavioural analytics: deep charts, governance and a large team behind it. Choose Dataflare if you want the essentials (trends, funnels, retention, cohorts, replay and experiments) in your own Cloudflare account, without per-event pricing or a sales call, and with SQL you can read under every number. - [Dataflare vs Mixpanel](https://dataflare.dev/vs/mixpanel/): Mixpanel is fast, polished event analytics with a generous free plan. Choose Dataflare if you want your events in your own Cloudflare account, prefer Cloudflare's prices to per-event tiers, or want an agent to answer analytics questions with the SQL to back them up. - [Dataflare vs Umami](https://dataflare.dev/vs/umami/): Umami is a clean, open-source web analytics tool with funnels and retention, and a free cloud tier. Choose Dataflare if you want to self-host without running a server or database, or need session replay and experiments without moving to a higher plan. - [Dataflare vs Cloudflare Web Analytics](https://dataflare.dev/vs/cloudflare-web-analytics/): Cloudflare Web Analytics is free and needs no setup if your site is already behind Cloudflare. It counts page views and visitors, and doesn't support custom events. Dataflare runs on the same platform, in your account, and covers what comes next: events, funnels, retention, people, replay and experiments. ## Cost Dataflare has no subscription. It runs in the user's Cloudflare account and costs Cloudflare's list prices: small sites fit Workers Free ($0); Workers Paid is $5/month and includes 10M requests and 50M D1 rows written. Dataflare uses about 3 Worker requests per page view and 5 D1 row writes per event. Calculator: https://dataflare.dev/pricing/ ## Source - Repository (MIT): https://github.com/ISNIT0/glass-analytics - Changelog: https://dataflare.dev/changelog/