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

# Set up nextanalytica

You are helping a user set up nextanalytica. nextanalytica is headless web analytics for your own AI agent: one tag collects your site's visits, your agent (Claude, Cursor, Codex or any MCP client) reads them through our MCP server, and skills on a schedule tell your team what changed and what to fix. Aim to do the whole setup from this one prompt: the user signs in, answers a few questions and approves the change to their site's code. You do the rest.

## Before you start

- **Reply first.** Your first message is the step 1 questions. Before it, read only local files that help you guess the answers (package.json, the framework's config, the site's layout, any analytics tag already there). Don't search the web.
- **Know where you run.** With the project and a terminal (Claude Code, Cursor, Codex), follow every step. In a chat without the code, do steps 1 to 3, then give the user the tag line from `get_tag` and where it goes.
- **Never** write a tag from memory (it carries the project's own token), and never ask for a password.

## 1. Ask what they want

Ask in one message, each with your best guess, so the user can reply "ok":

1. **Which site?** The domain, for example `shop.example.com`.
2. **Where is its data kept?** The EU (Frankfurt) unless the dashboard offers another region. It can't move later.
3. **Does the site ask visitors for consent?** If it has a cookie banner (Google Consent Mode v2, Cookiebot, OneTrust), the tag can read it; otherwise it counts without cookies until a yes.
4. **Do people sign in on the site?** If so, the tag can know them after consent (`identify` on sign-in, `reset` on sign-out).

## 2. Connect

If you already have the nextanalytica tools (`get_context`, `list_projects`), skip this step. If a nextanalytica server at this address is there but doesn't work (a 401, or only a `reconnect` tool: its key was revoked or expired), remove it first (`claude mcp remove nextanalytica` in Claude Code) and add it again without a key. Otherwise add the remote MCP server and name it nextanalytica:

- Claude Code: `claude mcp add --transport http nextanalytica https://mcp.nextanalytica.app/mcp`, then `/mcp` and nextanalytica.
- Claude (web or desktop): Settings, Connectors, Add custom connector, paste the address, Connect.
- Codex: `codex mcp add nextanalytica --url https://mcp.nextanalytica.app/mcp`.
- Cursor and any other client: add `https://mcp.nextanalytica.app/mcp` as a remote MCP server.

Signing in is the user's step: OAuth in the browser, and signing in for the first time makes the account. Tell them how in one line and wait. If they land on a waitlist, stop and tell them.

## 3. Add the site

Call `list_projects`. If the site isn't there, the user adds it at https://dash.nextanalytica.app (Add a project: the domain, the region, the time zone) and tells you when it's done. Then call `list_projects` again.

## 4. Add the tag

1. Call `get_tag` for the site. It returns the line and where it goes in the project's framework.
2. Put the line in the `<head>` of every page, in the shared layout ([where, per framework](https://nextanalytica.app/install.md)). If the user said the site has a consent banner, call `nextanalytica.consent(true)` where the banner's yes is handled, and `consent(false)` where its no is. If people sign in, add `nextanalytica.identify(userId)` after sign-in and `nextanalytica.reset()` on sign-out.
3. Show the user the change and ask before you commit or deploy it.

## 5. Test and check

After it's deployed, ask the user to open the site once. Call `get_tag` again: the domain turns live within about a minute. Then `get_live` shows the visit.

## 6. Report

In a few lines: what you changed and where, that the domain is live, and the next three things worth doing: say what counts as a conversion (`set_conversions`, after the user agrees; owners and admins only), connect sources in Sources (${openSourceNames()}; each has a "Not set up yet?" message when there's nothing to connect), and switch on a skill such as the Weekly check-up.

## If the site already has analytics

Keep it. nextanalytica runs next to Google Analytics and the rest; Google Analytics 4 can be connected as a source, and the tag reads the events a site already pushes to Google's `dataLayer`. Don't remove another tool unless the user asks.

## Help

Everything for agents: [llms.txt](https://nextanalytica.app/llms.txt). The server and its tools: [MCP brief](https://nextanalytica.app/mcp.md). Questions: [FAQ](https://nextanalytica.app/faq.md).

Canonical address: https://nextanalytica.app/setup
