Add privacy-friendly analytics
You can learn which pages work and where people drop off without tracking anyone across the web. Here is how to wire it up cleanly.

Key takeaways
- Privacy-friendly tools such as Plausible, Fathom, Simple Analytics and Umami count visits without cookies or cross-site profiles. Their site ID is public; their API keys are not.
- Add a handful of custom events for the moments that matter, and never put emails, names or tokens in URLs or event properties.
- A first-party events table in your own backend is a solid alternative when you want the data next to your product data.
To add privacy-friendly analytics, sign up for a cookieless analytics service (Plausible, Fathom, Simple Analytics, or Umami, which you can also self-host), add your site in its dashboard, and paste its one-line script into your app's HTML head. Page views start appearing within minutes. Then add a few custom events for signups and purchases, and check that no personal data leaks through URLs. These tools count visits without cookies and without following people across other sites, which keeps both your visitors and your privacy policy simpler.
Deciding *what* to measure is its own job, covered in setting up app analytics. This page is about installing a privacy-friendly tool correctly.
Choosing a tool
The hosted options are similar in spirit: a lightweight script, no cookies, aggregate dashboards (top pages, referrers, countries, devices), custom events and a paid subscription after a trial. Umami is open source, so you can self-host it for free if you are happy to run a server and database, or use its hosted plan. Compare current pricing, data location (several are EU-hosted, which matters to some customers) and whether you need features like funnels or revenue tracking. Prices and plan limits change, so check each provider's page rather than a comparison table.
- Pick a hosted tool if you want it working today and do not want to maintain anything.
- Self-host Umami if you have many small sites and want one dashboard without per-site fees.
- Build a first-party events table (below) if you want analytics joined to your product data, like 'signups who created a second project within a week'.
Installing the script
Each tool gives you a script tag with your domain or site ID, for example a tag with `data-domain="tidepool.app"` pointing at the provider's script URL. In a Startbase web project this goes in `index.html` at the project root, inside `<head>`, with `defer` so it never blocks the page. The site ID is public by design: every visitor's browser sends it. Unlike most keys in this cluster, it does not belong in Secrets.
Two details for single-page apps. First, page changes happen without a full reload, so confirm your tool records route changes; most of these scripts listen to the browser's history API automatically, but test by clicking between pages and watching the live view. Second, exclude previews and your own visits: most tools let you restrict tracking to listed domains, so add only your published `*.startbase.app` address and custom domain, and use the tool's opt-out (often a localStorage flag) on your own browsers.
Custom events for the moments that matter
Page views tell you where people go. Events tell you whether they did the thing. For a booking app, five events cover most questions:
- `Signup` with property `method: email | google`
- `Booking started` with `service_category`
- `Booking completed` with `service_category` and a rounded `price_band` such as `25-50`
- `Upgrade` with `plan`
- `Share link copied`
Fire `Booking completed` after the server confirms the booking, not when the button is clicked, or failed payments count as successes. Keep property values to small fixed sets: a property with thousands of distinct values (like a user id) is both useless in an aggregate dashboard and a privacy problem. Set each event up as a goal in the tool so it shows conversion rates.
The first-party option
If you would rather keep analytics in your own database, a small setup does it. A public `track` edge function accepts `{ name, path, referrer, props }`, rejects unknown event names, rate-limits per IP, and inserts into an `events` table. Store a daily visitor hash instead of the IP: hash the IP plus user agent plus a salt that rotates every 24 hours, so you can count unique visitors per day but cannot follow anyone across days. A nightly scheduled job rolls raw events into a `daily_stats` table and deletes raw rows older than, say, 90 days. An admin page charts `daily_stats`.
You give up polish (no ready-made referrer parsing or country maps) and gain joins: 'of the people who completed a booking in October, how many booked again in November' becomes one SQL query against your own tables.
Reading the numbers in the first month
Early traffic is small and noisy, so resist reacting to single days. Look weekly at three things. Which referrers send visitors who complete a goal, not just visitors: a forum thread that sends 40 people and 6 signups beats a directory listing that sends 400 and none. Which landing pages have the highest bounce, since those are the promises your page does not keep. And the conversion rate from `Booking started` to `Booking completed`, which tells you whether checkout loses people. If it drops after a release, that is a bug report, and your error tracker is the next place to look.
Paste-ready brief
Add privacy-friendly analytics with Plausible to my booking site. Put the Plausible script in the head of index.html with defer and data-domain set to my published domain only, so previews are not counted. Track route changes in the single-page app. Add custom events: Signup (method), Booking started (service_category), Booking completed (service_category, price_band rounded to 25 dollar bands) fired only after the server confirms, Upgrade (plan) and Share link copied. Never send emails, names, user ids or tokens in events or URLs; move any token in a query string to the URL hash or a POST body. Add a line to the privacy page saying we use cookieless, aggregate analytics and naming the tool.
Pitfalls
- Personal data in URLs. Paths like `/invite?email=ana@example.com` or `/reset?token=...` get recorded as page views. Keep identifiers out of query strings, or strip them before tracking.
- Counting previews and yourself. Without a domain restriction, every agent test run and your own clicking inflate the numbers, especially early on when traffic is small.
- Ad and tracker blockers. Some visitors block analytics scripts entirely, including privacy-friendly ones, so treat totals as a floor. Compare trends, not absolute numbers. Your backend's own counts (signups, bookings) are the ground truth.
- Leaking the stats API key. The site ID is public; a stats API key that reads your data is not. If you pull numbers into an admin page, call the API from an edge function with the key in Backend → Secrets.
- Assuming 'cookieless' settles the legal question. Cookieless analytics often avoids a consent banner, but the rules depend on where you and your users are and what you collect. Describe the tool in your privacy policy and see the GDPR basics.
- Mobile apps. These script tags are for websites. For an Expo app, send events to your first-party `track` function or to the tool's events API from your backend.
Frequently asked questions
Do privacy-friendly analytics tools need a cookie banner?
Cookieless tools that collect no personal data often run without one, which is a main reason to choose them. The rules depend on your jurisdiction and setup, so describe the tool in your privacy policy and check what applies to you.
Is it safe to put the analytics script ID in my frontend?
Yes. The site ID or domain in the script tag is public by design. Any API key that reads your stats is secret and belongs in Backend → Secrets, used from an edge function.
Why do my analytics numbers not match my signups?
Blockers stop some scripts, events fired on click can count failed attempts, and previews may be counted. Trust your backend counts for signups and sales, and use analytics for trends and drop-off.
Can I build my own analytics instead?
Yes. A public track function, an events table with a daily rotating visitor hash, and a nightly rollup job give you aggregate analytics that join directly with your product data.

