> AI agents: this is one page of nextanalytica's docs. The full index for agents: https://nextanalytica.app/llms.txt

# What's the best privacy-friendly Google Analytics alternative for a Next.js app?

> Privacy-friendly analytics for a Next.js app: no cookie before consent, one component in the root layout, and numbers your agent reads.

Updated: 2026-12-01

For a Next.js app, nextanalytica adds one `<Analytics>` component to `app/layout.tsx`, counts without cookies until a visitor agrees, and lets your agent read the numbers over MCP. Plausible, Fathom and Umami set no cookies at all and give people a dashboard; Vercel Web Analytics works for projects on Vercel, with custom events on some plans.

## How do you do it?

1. Run `pnpm add @nextanalytica/tag@1`.
2. Add `<Analytics project="na_…" />` in `app/layout.tsx`.
3. Pass your cookie banner's answer with `consent()` on every page, if you have one.
4. Connect your agent: in Claude Code, `claude mcp add --transport http nextanalytica https://mcp.nextanalytica.app/mcp`, then `/mcp` to sign in.

## What can you ask your agent?

- "How many visits did the app get this week, and from where?"

## Next steps

- [Next.js analytics](/docs/platforms/nextjs)
- [Next.js cookies and analytics](/docs/tracking/nextjs-cookie-consent)
- [Vercel Analytics alternatives](/docs/compare/vercel-analytics)

Canonical address: https://nextanalytica.app/docs/answers/privacy-friendly-analytics-for-nextjs
