Lovable
Add nextanalytica to a Lovable app with one prompt in Lovable's chat, then ask your own agent about visits, sign-ups and AI traffic.
Updated
Lovable builds web apps from a chat and hosts them on a lovable.app address. To count your app's visits with nextanalytica, ask Lovable's chat to add the tag to every page, then publish.
How do you add nextanalytica to Lovable?
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.
Lovable has no setting for code in the <head>, so the chat is the way in. Apps made since May 2026 use TanStack Start, where the head is set in the root route; older apps use React with Vite, where it's index.html. The prompt works for both. See Lovable's site metadata docs.
Can you edit the code yourself?
Yes, on a paid Lovable plan, in Code mode. On any plan, connect the project to GitHub and add the line there: Lovable syncs both ways. In an older Vite app, the line goes in index.html:
<head>
<!-- the rest of your head -->
<script async src="https://t.nextanalytica.app/t.js" data-project="na_…"></script>
</head>In a TanStack Start app, follow TanStack Start.
Can Lovable's chat connect to nextanalytica?
Lovable adds remote MCP servers as chat connectors on every plan.
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 Lovable's own analytics?
Lovable counts visits, pages, sources and devices for published apps on its own. 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 Why not the builder's own analytics?
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.