How to add analytics to a Lovable, Bolt or v0 site

Each of the three builders now counts some visits on its own. If you want your own tool as well, the tag goes in a different file in each one, and the builder's AI won't always put it there.

8 min read

Summarize with

In this article
  1. 1Check what your builder already counts
  2. 2Copy the whole snippet first
  3. 3Where the tag goes
  4. 4Five ways the install goes wrong
  5. 5Check that pageviews arrive
  6. 6When the builder and your tool disagree
  7. 7Visits from AI assistants
  8. 8A short checklist

Lovable, Bolt and v0 take a site from a prompt to a live address quickly. Seeing who visits it is a separate step, and the builder's AI doesn't always put tracking code where it belongs.

This guide works for any analytics tool that installs with a script tag. It covers what each builder already counts on its own, where the tag goes in each one, how to check that pageviews arrive, and what to expect when two tools disagree. These products change their interfaces and plans often, so the details below are as of November 2026.

Check what your builder already counts

All three can show you some traffic before you add any code of your own.

BuilderWhat's built inWorth knowing
LovableAnalytics on all plans. It starts counting when you publish, with nothing to set up. Open More → Analytics in the project toolbar.Sets no cookies. Puts AI assistants such as ChatGPT and Perplexity in one SEO & AI channel, together with search engines.
BoltAnalytics for sites published to Bolt Hosting on a paid plan, under All project settings → Analytics.Includes visits from crawlers and bots, and shows up to the last 30 days.
v0v0 publishes to Vercel, and Vercel Web Analytics is available on all Vercel plans. Turn it on under Analytics in the v0 project's settings.For Next.js, Vercel's quickstart also has you install its @vercel/analytics package and add its component to the root layout. Traffic it identifies as automated isn't counted.

The table follows the documentation from Lovable, Bolt and Vercel. If the built-in numbers answer your questions, you may not need anything else. A separate tool earns its place when:

  • the built-in option isn't on your plan, or the site is hosted somewhere other than the builder's own hosting;
  • you run sites built in different places and want them on one dashboard;
  • you want more history than the builder shows, or a view it doesn't have;
  • you need to follow steps such as sign-up and purchase. Lovable's own docs point to a dedicated tool such as PostHog for that.

Copy the whole snippet first

Find the install snippet in your analytics tool's settings. It usually carries your site id or your domain. Some tools give you one line. Others give you several, sometimes two script tags. Copy all of it, exactly as shown.

Keep a copy in a text file. You'll paste the snippet into the builder's chat or code editor, and afterwards you'll want to compare what ended up in the project with what you copied.

Where the tag goes

The rule is the same everywhere: the tag belongs, once, in the shell that every page shares. In most projects that's the shared <head>; in Next.js it's the root layout. Put it there and the whole site is covered. Put it in one page's component and only that page is tracked. What differs between the builders is which file that is.

Lovable

Lovable changed the stack for new apps in 2026. According to its FAQ, apps created from May 13, 2026 (June 22 for Enterprise workspaces) use TanStack Start and render pages on the server. Older apps use React and Vite and render in the browser. If you don't know which one you have, Lovable's docs suggest asking in the chat: “What stack is this project on?”

  • React and Vite (older projects). The shared shell is index.html at the project root. The tag goes just before </head>.
  • TanStack Start (newer projects). The shell is the root route, src/routes/__root.tsx, which renders the <html> and <head> of every page. The tag goes inside that <head>, next to <HeadContent />. Listing the script in the root route's head() function works too.
src/routes/__root.tsx, the part that renders <head>
<head>
  <HeadContent />
  <script
    defer
    src="https://analytics.example.com/script.js"
    data-site="YOUR_SITE_ID"
  />
</head>

The address and attributes here are placeholders. Use the ones from your own snippet.

To paste it yourself, open the code editor. Anyone with edit access can read the code there, but on the Free plan the editor is read-only, so editing by hand needs a paid plan.

Then publish. Lovable's live site keeps showing the version you last published until you publish again. If you later upgrade an older project to TanStack Start, Lovable says the upgrade moves analytics scripts into the new template. Check once afterwards that the tag is still there.

Bolt

Bolt picks a framework when a project starts, and you can ask for a particular one in your prompt. Its default is React, Vite, Tailwind CSS and Node.js, so most Bolt projects have an index.html at the root, and the tag goes in its <head>, the same way as in an older Lovable project. If the file tree shows an app folder and a next.config file instead, it's a Next.js project: use the Next.js steps under v0 below.

Bolt's help pages say you can paste tracking code in Code view or ask Bolt in the chat to add it, and they leave where it goes to your analytics provider's instructions. Code view isn't available on mobile, and in Safari the project files are read-only, so edit by hand from a desktop Chromium-based browser such as Chrome or Edge.

Publishing works much like Lovable. Changes you make after publishing aren't applied to the live site until you click Update in the Publish menu.

v0

v0 defaults to Next.js and follows the App Router's conventions. A Next.js App Router project has no index.html to edit. The shell every page shares is the root layout, app/layout.tsx.

For third-party scripts, the Next.js docs use its Script component. In the root layout, a script loads on every route, and Next.js makes sure it loads only once as visitors move between pages:

app/layout.tsx, shortened
import Script from "next/script";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
      <Script
        src="https://analytics.example.com/script.js"
        data-site="YOUR_SITE_ID"
      />
    </html>
  );
}

Three details from the Next.js docs help here:

  • The default loading strategy, afterInteractive, is the one it suggests for analytics, so you don't need to set one.
  • Attributes the Script component doesn't use itself, such as data-* attributes, are passed through to the final script tag.
  • If your snippet contains inline code between the tags, that part goes in its own Script with an id.

If your analytics tool publishes Next.js instructions of its own, follow those instead. Then publish with the Publish button in the chat header. On a project that's already live, v0's docs call this step Publish Changes. Preview deployments get their own URLs and don't change the production one.

Five ways the install goes wrong

  • The AI rewrote the snippet. It can turn the tag into a fetch call, rename an attribute or drop the site id. Compare the project with your saved copy.
  • The tag landed in one page component. Only that page gets tracked.
  • The change was never published. The editor has the tag. The live site doesn't.
  • The tag is there twice, for example once in the shell and once in a component. Depending on the tool, every pageview can then be counted twice.
  • A Content Security Policy blocks it. If the project sets one, the tool's domain has to be allowed for scripts, and usually for the requests the script sends.

Check that pageviews arrive

Don't assume it works. Check, in this order:

  1. Open the live site, not the preview. The preview isn't the site your visitors see. In Bolt it runs inside your own browser, and in v0 preview deployments have URLs of their own. Use your own domain, or the address ending in lovable.app or bolt.host, or your Vercel production URL.
  2. Turn off ad blockers for the check, or use a browser profile without extensions. Many of them stop analytics scripts.
  3. Open the developer tools and go to Network. Reload the page and filter by your tool's domain or the script's file name. Look for the script loading without an error, followed by a request that sends the pageview.
  4. Look at the Console for errors that mention the script. A script blocked by a Content Security Policy shows up here.
  5. Open your tool's live or real-time view, if it has one. Your visit should appear within a short time.
  6. Click through to another page. Sites built with these tools usually change pages without a full reload, and a second pageview should still appear. If it doesn't, look in your tool's docs for single-page apps, and see why single-page apps trip up some tools.
  7. Search the Elements panel for the script's address and confirm the tag appears once.

If the script loads and still nothing shows up, check the site id and the address you registered with the tool. Some tools ignore pageviews from addresses they don't expect. Plausible, for example, has a hostname allow list, and once it's set, traffic from every other hostname is blocked.

Test on the address your visitors use. The preview is for you, not for your analytics.

When the builder and your tool disagree

Run a builder's analytics next to your own tool and the numbers won't match. That's expected, because they count different things:

  • Bots. Bolt says its figures currently include visits from crawlers and bots. Vercel leaves out traffic it identifies as automated from the user agent, and Lovable filters bots out as well. Your tool has rules of its own.
  • Blockers. A tool that counts through a script in the browser misses visitors whose ad blocker stops that script.
  • What a visitor is. Lovable gives each visit a random identifier that it discards when the visit ends. Vercel uses a hash that resets every day. Other tools define a unique visitor differently again.
  • Days and ranges. A day in one dashboard isn't always the same 24 hours in another.

Compare the trend, not the totals. There's a longer walk through each cause in why no two analytics tools agree on your traffic.

Visits from AI assistants

A click from ChatGPT, Perplexity or another assistant can be identified when the visit carries the assistant's site as its referrer, or a utm_source tag on the link. Lovable's built-in analytics counts those in its SEO & AI channel, together with search engines, so a rise there could come from either.

A visit with neither signal, for example from a link opened in a desktop or phone app, is counted as direct traffic. So the AI visits you can see are a floor, not the full count. The guide to tracking ChatGPT traffic shows how to find them in GA4 and other tools.

A short checklist

  • See whether your builder's own analytics already answers your questions.
  • Copy the whole snippet and keep a copy.
  • Lovable: index.html, or src/routes/__root.tsx in a TanStack Start project. Bolt: check the framework first. v0: app/layout.tsx.
  • Publish or update, or the live site won't have the tag.
  • Verify on the live address with blockers off: Network panel, live view, a second page.
  • Expect the builder and your tool to disagree, and compare trends.

Lomen is one of the script-tag tools this guide is written for. It installs with one script tag, with no API key, package or build step, so on Bolt and v0 it goes wherever the steps above put it. For Lovable there's a prompt to paste into the project's chat, and in the Lomen dashboard it comes with your site id filled in. The script sets no cookies and IP addresses are never stored. It doesn't track custom events or funnels, so if following people from sign-up to purchase is what you need, it's the wrong tool for that job.

Numbers you can ask questions

Lomen is one cookie-free script: sources, campaigns and AI referrals on one dashboard, and an AI that answers from your own figures. Free during the beta, no credit card.