Sign inGet started

Install nextanalytica

View as MarkdownOpen in ChatGPTOpen in Claude
Connect your agent
Add to CursorAdd to VS Code

Where the nextanalytica tag goes in each framework, and how consent and sign-ins work.

Updated

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.

The fastest way: connect your agent to https://mcp.nextanalytica.app/mcp and ask it to call get_tag for the site; it gets the project's own line and adds it for you. By hand, the line is:

<script async src="https://t.nextanalytica.app/t.js" data-project="na_…"></script>

na_… is the project's own token. Take it from get_tag or the Tracking window; never make one up. The line goes in the <head> of every page. Single-page navigation is counted on its own, and the same line works on subdomains.

Where it goes

  • Plain HTML, WordPress, Webflow, Framer, Shopify and other site builders: Paste the script line into the <head> of every page, or of the shared layout or template (Google Tag Manager works too: a Custom HTML tag on All Pages).
  • Next.js: app/layout.tsx: import Script from "next/script", then <Script src="https://t.nextanalytica.app/t.js" data-project="na_…" strategy="afterInteractive" /> inside <body>. Pages Router: the same in pages/_app.tsx.
  • React, Vue or Svelte with Vite: index.html: the script line inside <head>.
  • Nuxt: nuxt.config.ts: app: { head: { script: [{ src: "https://t.nextanalytica.app/t.js", async: true, "data-project": "na_…" }] } }.
  • SvelteKit: src/app.html: the script line inside <head>.
  • Astro: The shared layout's <head> (for example src/layouts/Layout.astro): the script line, with is:inline.
  • Remix and React Router: app/root.tsx: the script line inside <head> in the Layout or root component.
  • Without consent the tag counts page views without cookies: nothing kept across visits, nobody identified.
  • After the visitor agrees, call nextanalytica.consent(true); the tag can also read the site's banner (Google Consent Mode v2, Cookiebot, OneTrust) when that's switched on in Tracking.
  • When someone signs in, call nextanalytica.identify(userId, properties); on sign-out, nextanalytica.reset(). To count nothing until consent, add data-cookieless="off" to the line.
  • Your own events: nextanalytica.track(name, props); orders: nextanalytica.order({ ref, value, currency }).

Check it works

Open the site once. The first page view proves the site is yours; the domain turns live within about a minute (get_tag says so), and visits are stored from the next page view on.