v0
Add nextanalytica to a Next.js app built with v0: a prompt in v0's chat or one script in app/layout.tsx, then ask your own agent about visits.
Updated
v0 is Vercel's app builder: it writes Next.js apps with React and deploys them to Vercel. To count your app's visits with nextanalytica, add the tag once, in the root layout, through v0's chat or the Code tab.
How do you add nextanalytica to v0?
Copy your tag line from Site in nextanalytica, then paste this into the builder's chat, with your line in place of the example:
Add this script tag inside <head> on every page, in the root layout, exactly as written. Don't change it and don't add anything else:
<script async src="https://t.nextanalytica.app/t.js" data-project="na_…"></script>na_… is your project's key. Never let the builder write the line from memory: a made-up key counts nothing. Then publish the app, since the tag only counts the published version.
Where does the tag go if you edit the code?
In the Code tab, open the root layout: app/layout.tsx, or src/app/layout.tsx when the app has a src folder. Add the tag with next/script:
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script src="https://t.nextanalytica.app/t.js" data-project="na_…" strategy="afterInteractive" />
</body>
</html>
);
}Keep what the layout already has, such as fonts and other components; add only the Script line and its import. For the npm package instead of the line, see Next.js analytics.
Can v0's chat connect to nextanalytica?
v0 adds custom MCP servers with OAuth.
The builder's chat can also connect to nextanalytica as a custom MCP server, with the address https://mcp.nextanalytica.app/mcp and OAuth. Its agent can then take your tag line from get_tag and check the setup with check_setup, instead of you copying the line. Builders use MCP servers only while building: the published app never calls them.
What about Vercel Web Analytics?
v0 apps can use Vercel Web Analytics, switched on in the Vercel project. Keep it if you like. Add nextanalytica when you want conversions, AI assistants as their own channel and your own agent reading the numbers. See Vercel Analytics alternatives.
How do you check it works?
Publish the app and open it once in your browser. Within about a minute, Site shows the domain as live. If your agent is connected, ask it "Check my nextanalytica setup": check_setup lists the hosts that sent something and what to do next.
How do you count sign-ups and other actions?
The tag counts visits and pages on its own. Actions only your app knows about, such as a sign-up, need one line where they happen. Ask the builder's chat to add it after the sign-up succeeds:
window.nextanalytica?.track("signup_completed", { plan: "team" });Then tell your agent which events count as conversions, and it reads conversion rates by channel and page. See Custom events.
Do you need a cookie banner?
Not for the tag. It counts without cookies until a visitor agrees, so people who never answer a banner are still counted. If your app has a banner, pass the answer with window.nextanalytica?.consent(true) or consent(false). See Cookieless counting and consent.
What can you ask your agent?
Connect your own agent (Claude, Cursor, Codex) to nextanalytica once, and ask in plain words:
- "How many people visited the app this week, and from where?"
- "Which channel brings sign-ups?"
- "I deployed a new version. Did I break anything?"
See Your agent to connect it.