surendrapandar/minilytics
소개
인디 해커와 1인 창업자를 위한 오픈 소스 수익 우선 분석 도구
AI 및 머신러닝측정된 스타 증가
- in 24h
- +1
- in 7 days
- +4
- in 15 days
- +7
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalMinilytics
Revenue-first web analytics for your own websites, inspired by DataFast. It shows where visitors came from (which tweet, article, Google page or AI assistant), what they did, and which source made you money. It runs on Cloudflare's free plan.
Built by Surendra Pandar. Say hi, share what you build with it, or follow along as it grows:

Sponsors
![]() SnitchFeed Agentic social listening for GTM: X, LinkedIn, Reddit & more |
![]() Open Source Alternatives Find Best Open Source Alternatives to Paid Software |
![]() Awesome Black Friday Deals Black Friday & Cyber Monday deals for devs & indie makers |
|
DiskMate Disk space analyzer & cleaner for Mac |
PasteBuddy Clipboard history for Mac: never lose what you copy |
Your logo here Reach indie hackers and developers who self-host their analytics Become a sponsor → |
What it tracks
- Visitors, revenue, conversion rate, revenue per visitor, bounce rate, session time, online now, each with a % change against the previous period
- A chart of visitors (line) and revenue (bars), hourly, daily, weekly or monthly
- Date ranges: today, yesterday, last 24h, last 2 days, 7/30/90 days, 12 months, all time and custom, with ‹ › to step back and forward
- Where visitors come from: channel, referrer (X, Google, ChatGPT, Reddit…), campaign (
utm_campaign), keyword (utm_term),?ref=tags - Where they are and what they use: country, region, city, browser, OS, device
- What they did: pages, entry pages, exit links (outbound clicks), button clicks and custom goals, funnels
- Who paid: a Journey list of every customer with their source, amount, time to convert, and a full visitor timeline (visit → pages → clicks → payment)
- Live globe (press
M): every visitor on your site right now, on a 3D globe or 2D map, with a live feed of page views, goals and payments, optional sounds, light/dark map and fullscreen. Map tiles from OpenFreeMap, free with no API key - Anonymous visitors get friendly, stable names like "brown fox"
- Click any row to filter the whole dashboard (for example "only visitors from the launch tweet")
- Import from DataFast / Plausible: upload historical exports (.zip or .csv) from the web dashboard or CLI
- Multiple websites, one login
- Ask your AI: connect Claude, ChatGPT or Cursor over MCP and ask "which tweets made me money this month?" (how)
Deploy for free (about 10 minutes)
Every person deploys their own copy on their own free Cloudflare account. Your data stays on your account, and you get your own dashboard with its own password.
You need a free Cloudflare account, Node.js 20+ and Git. Run these commands in a terminal on your computer. You only do this once; afterwards the app runs on Cloudflare.
1. Download the code and log in to Cloudflare
git clone https://github.com/surendrapandar/minilytics.git
cd minilytics
npm install
npx wrangler login # opens your browser; click "Allow"
2. Create the database
npx wrangler d1 create minilytics
If Wrangler asks "Would you like Wrangler to add it on your behalf?", answer No. Answer No to the optional
"Cloudflare skills" questions too. Then copy the printed database_id and paste it into wrangler.jsonc, replacing
00000000-0000-0000-0000-000000000000. There must be exactly one entry under d1_databases, with "binding": "DB".
3. Set your password and a signing secret
npx wrangler secret put ADMIN_PASSWORD # the password you'll log in with (use a strong one)
npx wrangler secret put SESSION_SECRET # any long random text, e.g. the output of: openssl rand -hex 32
Typing is hidden; that's normal. If asked "There doesn't seem to be a Worker called minilytics… create it?", answer Yes.
4. Deploy
npm run deploy
This builds the dashboard, creates the database tables and deploys. It prints your link, e.g.
https://minilytics.<you>.workers.dev. Open it, log in, add a website and copy its script tag. Each site's Settings
page also has a Copy AI prompt button that lets Claude Code / Cursor do the install in your codebase for you.
If you see fetch failed, it's a network hiccup (VPN, proxy, Wi-Fi). Run npm run deploy again.
You can attach a custom domain such as analytics.yourdomain.com in Cloudflare → Workers & Pages → minilytics →
Settings → Domains & Routes.
Updating later
git stash # keeps your database_id edit in wrangler.jsonc safe
git pull
git stash pop
npm run deploy
What the free plan covers
| Cloudflare free limit | What it means here |
|---|---|
| 100,000 Worker requests/day | About 100k tracked events per day across all sites. The script and dashboard files are static and don't count. |
| 100,000 D1 rows written/day | About 10k pageviews per day |
| 5M D1 rows read/day | A dashboard load reads roughly 10 times the sessions in the range, so with 10k visitors/month that's hundreds of loads a day |
| 5 GB D1 storage | Years of data at side-project traffic |
At 5–10k visitors a month you'll use a few percent of this. If you outgrow it, Cloudflare's Workers Paid plan is $5/month.
Run it as a hosted SaaS (optional)
By default Minilytics is single-user with a password. Set the Google values below and it becomes a hosted product: a landing page with pricing, Sign in with Google, a paid plan through Dodo Payments, and every customer sees only their own sites. Tracking stops (quietly) for sites whose owner's plan has ended.
npx wrangler secret put GOOGLE_CLIENT_ID # Google Cloud → Credentials → OAuth client (Web)
npx wrangler secret put GOOGLE_CLIENT_SECRET # redirect URI: https://YOUR-DOMAIN/api/auth/google/callback
npx wrangler secret put ADMIN_EMAILS # your Google email(s): free, and you keep the existing sites
npx wrangler secret put PLAN_CHECKOUT_URL # Dodo payment link for the plan
npx wrangler secret put PLAN_PRODUCT_ID # that product's id (pdt_...)
npx wrangler secret put BILLING_WEBHOOK_SECRET # Dodo webhook → https://YOUR-DOMAIN/api/billing/webhook
npx wrangler secret put PLAN_PRICE # e.g. $29
npx wrangler secret put PLAN_INTERVAL # lifetime | month | year
npx wrangler secret put PLAN_SPOTS # e.g. 5 ("3 of 5 spots left"); optional
npx wrangler secret put PLAN_NEXT_PRICE # e.g. $49 ("…, then $49"); optional
npx wrangler secret put PLAN_TIERS # optional: "$29:5, $49:pdt_b:5, $100" steps the price up as spots sell
# (one Dodo product per price; no pdt_ = sold out or only announced).
# Replaces PRICE/SPOTS/NEXT_PRICE; sold-out prices show as "5 sold at $29"
npx wrangler secret put SUPPORT_EMAIL # shown on pricing, billing and legal pages
npm run deploy
Subscribe the billing webhook to payment.succeeded, subscription.* and refund.succeeded. A one-time product
(PLAN_INTERVAL=lifetime) gives lifetime access; a subscription gives access until it expires or is refunded.
The Terms, Privacy and Refund pages (/terms, /privacy, /refund) are plain-language starting points: review them.
Install on a website
<script defer data-website-id="SITE_ID" src="https://YOUR-MINILYTICS-HOST/js/script.js"></script>
- Button clicks / goals:
<button data-ml-goal="signup_click">, orwindow.minilytics('goal', 'signup', { plan: 'pro' }) - Identify logged-in users:
window.minilytics('identify', { user_id, email, name }) - Ignore your own visits: open
https://yoursite.com/?ml_ignore=trueonce per browser - Single-page apps (Next.js, React Router…) are handled automatically
- Subdomains:
app.yoursite.comandyoursite.comshare the same visitor, because the cookie is set on the root domain - No cookies at all: add
data-cookieless(see Cookieless mode)
Tracking a specific tweet / article
X, Medium, LinkedIn and others hide which exact post sent someone; the referrer only says t.co or medium.com.
To see the exact post, tag each link. Settings has a link builder for this:
https://yoursite.com/?utm_source=x&utm_medium=social&utm_campaign=launch-tweet
https://yoursite.com/?ref=launch-tweet (short version)
For SEO, Google never shares the search keyword, but Entry page with the Google referrer tells you which article people found you through.
Cookieless mode
Add data-cookieless to store nothing in the visitor's browser (no cookie, no local storage), for sites that can't
set cookies without asking for consent first (e.g. in the EU):
<script defer data-website-id="SITE_ID" data-cookieless src="https://YOUR-MINILYTICS-HOST/js/script.js"></script>
The server then identifies a visitor by a hash of a random daily salt, the site, the IP and the user agent. The salt is deleted when its UTC day ends, so a hash can't be traced back to an IP, and the raw IP is never stored. A visit still ends after 30 minutes of inactivity. What changes:
- A visitor is new every day. Visitor counts over several days add up the daily uniques, and journeys spread over several days aren't linked (subscription renewals still go to the first payment's visitor).
- Checkouts must be tagged on the day of the visit. There is no cookie to read on your server: send
window.minilytics.attribution()from the browser with the checkout or sign-up request and put it in the checkout metadata (Stripe: also insubscription_data.metadata, so the first invoice after a free trial is credited too). Payment links are tagged automatically, as in the default mode. - A proxied script must forward the visitor's IP, or every visitor looks the same (Vercel rewrites do).
- Subdomains count as your own site for outbound links only when you set
data-domain="yoursite.com".
Revenue attribution
Pick your provider in site settings → Connect payments.
Dodo Payments
- In Dodo → Developer → Webhooks, add
https://YOUR-HOST/api/webhooks/dodo/SITE_IDand subscribe topayment.succeededandrefund.succeeded. Paste the signing secret (whsec_…) into the site settings. - Pass the visitor cookies as metadata when creating a checkout:
const jar = await cookies(); // next/headers
await dodo.checkoutSessions.create({
product_cart: [{ product_id: 'pdt_xxx', quantity: 1 }],
metadata: { ml_visitor_id: jar.get('ml_vid')?.value ?? '', ml_session_id: jar.get('ml_sid')?.value ?? '' },
});
Using Dodo payment links? The script adds metadata_ml_visitor_id / metadata_ml_session_id to any
checkout.dodopayments.com link when it's clicked. That metadata doesn't always reach the payment, so also do step 3.
- Recommended: set the checkout's return / redirect URL to a page on your site (e.g.
/thanks) that loads the script. Dodo adds?payment_id=…to it, and Minilytics uses that to link the payment to the exact visitor even when metadata doesn't come through.
Stripe
- In Stripe → Developers → Webhooks, add
https://YOUR-HOST/api/webhooks/stripe/SITE_IDand subscribe tocheckout.session.completed,invoice.paidandcharge.refunded. Paste the signing secret (whsec_…) into the site settings. - Pass the visitor cookies as metadata when creating a Checkout Session, and add
{CHECKOUT_SESSION_ID}to the success URL:
const jar = await cookies(); // next/headers
await stripe.checkout.sessions.create({
// ...your existing options
success_url: 'https://yoursite.com/thanks?session_id={CHECKOUT_SESSION_ID}',
metadata: { ml_visitor_id: jar.get('ml_vid')?.value ?? '', ml_session_id: jar.get('ml_sid')?.value ?? '' },
});
Using Stripe Payment Links (buy.stripe.com)? The script puts the visitor in client_reference_id when the link is
clicked (unless you already set your own). Set the link's confirmation page to redirect to
https://yoursite.com/thanks?session_id={CHECKOUT_SESSION_ID} so the payment is also matched on the return page.
Subscription renewals (invoice.paid) are credited to the visitor who first subscribed. Refunds are subtracted.
One Stripe account selling for several of your sites? Point each site's webhook at Stripe as usual: a payment is
skipped by sites it clearly isn't for (the buyer was only seen on another site, or a renewal from a customer who only
paid on another site). To make it explicit, add ml_site_id: '<SITE_ID>' to the checkout's metadata.
Polar
- Open Settings & install → Connect payments → Polar in Minilytics. If your Polar organization sells for multiple sites, save the product IDs for each site before connecting its webhook.
- In Polar Settings → Webhooks, add
https://YOUR-HOST/api/webhooks/polar/SITE_IDwith the Raw format and API version2026-10. Subscribe toorder.paidandorder.refunded, then save the endpoint's signing secret in Minilytics. - On pages with the tracker, Polar Checkout Links carry the visitor and session in
reference_idwhen that parameter is available. When creating a Checkout Session in your backend, mergeml_visitor_idandml_session_idinto its metadata from theml_vidandml_sidcookies. For either checkout type, set the success URL to a tracked page such ashttps://yoursite.com/thanks?checkout_id={CHECKOUT_ID}.
Polar revenue includes paid orders after discounts and before tax, with full and partial refunds subtracted. Orders without a visitor match still contribute to site revenue.
To backfill earlier payments, open Import past Polar orders in the same panel and enter a Polar organization access token with orders:read. Use a dedicated test site for Sandbox data. Imports merge orders already received by webhook. For historical orders, the import uses the order's creation date for the sale and its last-modified date for any cumulative refund without a matching webhook.
How credit is given
A payment goes to the paying visitor's last visit that came from a real source (last non-direct
touch). So "clicked a tweet, came back directly 17 days later and paid" is credited to the tweet. If metadata is
missing, Minilytics tries, in order: the return page (?payment_id= / ?session_id= / ?checkout_id=), an earlier payment by the same customer
(renewals), an email you identify()'d, and finally checkout timing (used only when exactly one visitor clicked a Dodo or
Stripe checkout link in the 3 hours before the payment). The Journey tab shows how each payment was matched, and Try
matching again re-runs this for older payments.
Refunds are subtracted from revenue.
Other providers (API)
Any other provider can use the generic API (the key is in site settings):
curl -X POST https://YOUR-HOST/api/v1/payments -H "Authorization: Bearer ml_..." -H "Content-Type: application/json" \
-d '{"transaction_id":"txn_1","amount":29.99,"currency":"USD","visitor_id":"<ml_vid cookie>","email":"[email protected]"}'
Payment notifications
Get a push notification on your phone or computer when someone pays, with who paid and where they came from ("💰 +$29.00 · ShipKit — Jane · via X (launch)"). In site Settings → Notifications, click Turn on for this device. On iPhone and iPad, first add Minilytics to the Home Screen (Share → Add to Home Screen, iOS 16.4+) and turn it on from the installed app.
Each device chooses new payments, renewals and/or refunds, and can mute single sites. Standard Web Push, with nothing
to configure: the instance creates its own keys on first use, and messages are end-to-end encrypted, so the push
service (Apple, Google, Mozilla) can't read them. Set SUPPORT_EMAIL to give push services a contact for your instance.
Import from DataFast or Plausible
You can import historical analytics and revenue attribution into Minilytics from DataFast or Plausible export archives (.zip) or individual report .csv files.
From the Dashboard UI
- Open your site's Settings & install.
- Scroll to the Import data section.
- Drag and drop your
.zipexport or.csvfiles. - Inspect the summary card (visitors, pageviews, detected date range, revenue).
- Click Start Import. The dashboard will insert batches in real time with progress tracking.
From the CLI (ideal for massive histories)
# Local development D1 database:
npm run import:datafast -- --site <site-id> ./datafast-export.zip
# Production Cloudflare D1 database:
npm run import:datafast -- --site <site-id> --remote ./datafast-export.zip
Use it from AI assistants (MCP)
Minilytics is also an MCP server, so Claude, ChatGPT, Cursor and other AI tools can read your analytics and answer questions like "Which sources made the most money this month?", "Why did revenue drop this week?" or "Where do visitors drop off between /pricing and checkout?".
In the dashboard click ✦ Connect AI for copy-paste setup for each app. The server URL is:
https://YOUR-HOST/mcp
- Claude (web/desktop): Settings → Connectors → Add custom connector → paste the URL → Connect → Allow access.
- ChatGPT: Settings → Apps & Connectors → Advanced → turn on Developer mode → Create → paste the URL, OAuth.
- Claude Code:
claude mcp add --transport http minilytics https://YOUR-HOST/mcp, then/mcp→ Authenticate. - Cursor:
{"mcpServers": {"minilytics": {"url": "https://YOUR-HOST/mcp"}}}in~/.cursor/mcp.json. - Anything else: create a personal token under Connect AI and send
Authorization: Bearer mlp_....
Apps connect with OAuth (dynamic client registration and PKCE). You sign in to Minilytics and approve access, nothing to copy. Access is read-only: nothing can be changed or deleted. Every connected app and token is listed under Connect AI and can be disconnected at any time.
Tools: list_sites, get_overview (KPIs vs previous period + chart), get_breakdown (by source, channel, campaign, page, country, device, goal… sortable by revenue), get_realtime, list_customers (who paid and where they came from), list_visitors, get_visitor (one person's full journey), list_funnels, get_funnel (saved or ad-hoc steps). All take the same periods and filters as the dashboard.
Cost: it runs inside the same Worker and D1 database, with no extra services. Results are capped (100 rows max) and each token is limited to 150 calls per 5 minutes, so a chat costs a handful of requests and stays well inside the free plan.
Accuracy notes
No analytics tool is 100% accurate. These are the main gaps and how this project handles them:
- Ad blockers block some analytics domains. Proxy the script through your own domain (Settings shows a Next.js rewrite). Payments are always recorded by the webhook, even when the visitor's browser blocked tracking.
- Safari keeps cookies set by JavaScript for at most 7 days. A Safari visitor who returns after more than a week counts as new. The email fallback above recovers most of these payments. Cookieless mode has no such cap, but counts a visitor as new every day.
- Bots are filtered by user agent and the
navigator.webdriverflag. - Revenue in a different currency than the site's is converted only when Dodo gives a settlement amount in the site's currency.
Local development
cp .dev.vars.example .dev.vars # password: change-me
npm run db:migrate:local
npm run build && npm run dev:api # http://localhost:8787
npm run dev:web # optional: hot-reloading dashboard on http://localhost:5173
npm run seed # optional: 30 days of demo data ("ShipKit" site)
npm run seed:bots # optional: synthetic crawler data (run after seed)
npm test # unit tests
npm run smoke # end-to-end test against the running dev server
npm run smoke:bots # bot collection, filtering and isolation tests
node scripts/smoke-hosted.mjs # hosted-mode test (see the comment at the top for how to start it)
See the bot analytics guide for live server-side tracking setup and local testing details.
How it's built
public/js/script.js: the tracker, 9 KB (about 3.5 KB gzipped). It handles cookies, pageviews, engaged time, goals, outbound links and Dodo link taggingsrc/worker: a Hono app on Cloudflare Workers that handles event ingestion, the Dodo webhook, the payments and goals API, and stats queries on D1 (SQLite)src/dashboard: the React dashboard (Vite, Tailwind, Recharts), served as static files by the same Workermigrations/: the database schema
Contributing
Issues and pull requests are welcome. Before opening a PR, run npm run typecheck && npm test.
Questions, ideas or feedback? Reach me on X (@surendra_pandar) or LinkedIn.
License
MIT: free to use, modify and self-host, including commercially.
관련 프로젝트 살펴보기
불러오는 중…


