Getting Started
Deploy Flarelytics on Cloudflare in about 5 minutes. You'll need a Cloudflare account and Node.js.
Prerequisites
- A Cloudflare account (free tier works)
- Node.js 20 or later
- Wrangler CLI —
npm install -g wrangler - Cloudflare Analytics Engine enabled (available on all plans)
Log in to Wrangler before starting:
Clone & configure
Edit packages/worker/wrangler.toml with your values:
Find your
account_id on the Cloudflare dashboard under Workers & Pages — it's in the right sidebar on the overview page.
Deploy worker
After deploy, set the three required secrets:
Create the CF_API_TOKEN at dash.cloudflare.com/profile/api-tokens. Permissions required: Account > Account Analytics > Read.
Add tracking script
Add one script tag to your site's <head>. The script is auto-configured — no parameters needed.
Replace my-site-analytics with your worker name. If you prefer npm:
Enable scroll depth tracking (opt-in, uses IntersectionObserver):
Pageviews, outbound link clicks, and time-on-page are tracked automatically — including client-side navigation in single-page apps, where a route change fires a pageview without a full reload. The tracker also skips sending anything on localhost/127.0.0.1/file:// by default, so local dev doesn't pollute production data. Both are opt-out/opt-in via attributes:
Verify it works
Visit any page on your site, wait a few seconds, then run the query. You should see your path in the results.
View dashboard
Deploy the dashboard alongside your worker:
Open the dashboard URL from the deploy output and enter your QUERY_API_KEY when prompted. The dashboard works with multiple sites — use the site switcher to toggle between them.
Data retention
Event data lives entirely in Cloudflare Analytics Engine — Flarelytics has no database of its own and applies no additional retention logic on top. Analytics Engine keeps written data for three months, after which it's automatically removed. If you need longer retention, export query results on a schedule (the email reports worker is one way to do this) and store them yourself.
Was this page helpful?