Skip to Content
GenerateSaaS

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

SurfaceWrites analyticsOptOut
Web and desktop Settings → Profile analytics checkboxBoth ways, together with the browser consent. Shown where a banner is owed or PostHog is configured.
Web cookie banner Rejecttrue when signed in. Accept never clears it.
Sign-uptrue when the request carries acceptedCookies=false, or when the sign-up body sets it.
Mobile Settings → Privacy analytics switchBoth ways, beside the device's own choice.
Your codeauthClient.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 pathOpted-out user
trackServerEvent (every server event: purchases, subscriptions, credits_consumed, email_verified)Dropped
identifyServer and user_signed_upNot sent: no email, no created_at
MCP AnalyticsNo 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.

On this page