Analytics opt-out
One per-account switch that stops every server-side analytics report about a user, wired to the browser consent, the settings checkbox and the mobile privacy screen.
Browser consent only governs the browser. The server reports about signed-in people too - sign-up, payments, credit use, MCP tool calls, LLM generations - so each account carries users.analyticsOptOut (a Better Auth additional field, default false). Analytics is on by default; the opt-out lives in Settings.
What sets it
| Surface | Writes analyticsOptOut |
|---|---|
| Web and desktop Settings → Profile analytics checkbox | Both ways, together with the browser consent. Shown where a banner is owed or PostHog is configured. |
| Web cookie banner Reject | true when signed in. Accept never clears it. |
| Sign-up | true when the request carries acceptedCookies=false, or when the sign-up body sets it. |
| Mobile Settings → Privacy analytics switch | Both ways, beside the device's own choice. |
| Your code | authClient.updateUser({ analyticsOptOut }) |
The checkbox reads on only while the browser consents and the account is not opted out.
What it stops
Every server report keyed by that user's id is dropped - not anonymized, because a structural event tied to their id is still about them.
| Server path | Opted-out user |
|---|---|
trackServerEvent (every server event: purchases, subscriptions, credits_consumed, email_verified) | Dropped |
identifyServer and user_signed_up | Not sent: no email, no created_at |
| MCP Analytics | No identity; every $mcp_* event of the request dropped |
LLM analytics ($ai_generation) | Dropped for the whole run |
groupServer("organization", …) | Unchanged - an organization is not a person |
- One lookup decides:
analyticsOptedOut(userId)from@repo/analytics. It runs only in a process that reports, after the caller has returned, so no request waits on it. Call it before any new server capture you add outside the seam. - Fails closed: when the flag cannot be read, the report is dropped.
- Browser: unticking the checkbox revokes browser consent; where a banner is owed, PostHog keeps only an anonymous cookieless count.
Error reports are not analytics: Sentry and PostHog error tracking keep the user id on a crash whatever this flag says. The mobile app has its own crash-report switch.
Schema
The column is users.analytics_opt_out (boolean, default false). After updating, generate and apply the migration - see Schema changes.
MCP analytics
PostHog MCP Analytics for the outward MCP server - one event per tool call and listing, attributed to the signed-in user, with tool payloads off by default.
Google Ads conversions
Wire Google Ads conversion tracking onto the gtag.js that GA4 already loads with the ads key under config.analytics.google - conversion ID, per-event labels, and the Consent Mode v2 signals.