BlogGuide

How to add analytics to a v0 app

In this guide, we show you how to add analytics to an app you built with v0 in seven steps, from the script in your Next.js layout to your first funnel.

Every app v0 builds is a Next.js project that publishes to Vercel, which makes the first analytics option obvious: Vercel's own Web Analytics, switched on from the project's Analytics tab. It counts pages, referrers, countries and devices without cookies.

On Hobby, it stops early. You get 50,000 events a month, shared across every project on the account, and a one-month reporting window, while custom events need Pro and UTM campaigns need the Web Analytics Plus add-on. Visitors are identified by a hash that resets each day, so nobody can be followed from Monday's visit to Tuesday's sign-up.

Once people use your app, you'll want those things. This guide adds Spreelytics, which is free up to 1 million events a month and needs no server of your own. There are seven steps:

  1. Get your client key
  2. Ask v0 to add the script to your layout
  3. Allow your app's domains
  4. Publish and check it works
  5. Tag the clicks that matter
  6. Identify people when they sign in
  7. Build your first funnel

We checked the v0 and Next.js parts against their docs on 16 November 2026.

1. Get your client key

Sign up for Spreelytics and create an audience for your app, then open Settings → Tracking script and copy the client key it shows you.

The key is public on purpose. It can only send data into its own audience, so it's safe in your page source and in a public GitHub repo.

2. Ask v0 to add the script to your layout

v0 writes Next.js with the App Router, so the script belongs in the root layout, app/layout.tsx, which wraps every page. Next.js loads third-party scripts through its own Script component, and its docs name analytics as a good fit for the afterInteractive strategy.

Paste this into the v0 chat, with your key in place of YOUR_CLIENT_KEY:

In app/layout.tsx, import Script from next/script and add this inside <body>, after {children}. Don't change anything else.

<Script src="https://cdn.spreelytics.com/cdn/sdk/spreelytics-loader.js" data-client-key="YOUR_CLIENT_KEY" strategy="afterInteractive" />

The finished layout looks like this:

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

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://cdn.spreelytics.com/cdn/sdk/spreelytics-loader.js"
          data-client-key="YOUR_CLIENT_KEY"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}

You can also make the edit yourself in v0's Code tab and save it with Ctrl+S or Cmd+S.

There's no router code to add. Next.js moves between pages with the browser's history, and the script counts a page view each time the address changes, whether the visitor clicked a <Link> or your code called router.push(). Brought an older Pages Router project into v0? Our Next.js docs cover that too.

3. Allow your app's domains

Spreelytics only takes data from the hostnames on the audience's Allowed domains list, in Settings → Details. Add every address the app is published on:

  • the vercel.app address v0 gave your project
  • your custom domain, if you added one under Publish → Customize Domain, with and without www if both work

The preview inside v0 runs on a different hostname, so your own clicking around while you build stays out of the numbers. Preview deployments from GitHub branches get URLs of their own too, and you can leave those off the list unless you want test traffic counted.

4. Publish and check it works

Click Publish. If the app is already live, the button reads Publish Changes, and with GitHub connected, v0 merges its pull request and deploys.

Open the live app in a normal browser window and click around. Within a few seconds, Settings → Tracking script in Spreelytics should switch to Tracking is live, and you'll show up on the Realtime page.

Seeing nothing? Check the Allowed domains list first, then your own ad blocker.

5. Tag the clicks that matter

Page views say where people went. Clicks say what they did, and no tracking code is needed for them: any element with a data-spree-track attribute sends an event named after its value when it's clicked, which matters in Next.js, because most v0 components are server components and can't run an onClick.

Ask v0 something like:

Add data-spree-track="signup_clicked" to the sign-up button and data-spree-track="checkout_started" to the upgrade button.

Each click then lands on the Events page. For a detail, add data-spree-prop-plan="pro" too.

6. Identify people when they sign in

If your app has accounts, through Supabase or anything else v0 wired up, tell Spreelytics who signed in, and their earlier anonymous visits join their profile along with every visit after it.

Prompt v0 with:

Right after a user signs in or signs up, in a client component, call window.Spreelytics?.identify(user.email). When they log out, call window.Spreelytics?.reset().

Each person then gets a timeline of their visits, events and sources, from the first time they landed on the app. Identify users lists the extra details you can save.

7. Build your first funnel

A funnel counts how many people got through each step and where the rest left. Each step is a goal. So start on the Goals page, where a goal is either a page path, such as /pricing, or one of the events from step 5. Then open Funnels and put them in order, for example:

  1. visited /
  2. signup_clicked
  3. checkout_started

The step with the biggest drop is where your next prompt to v0 should go. Funnels run on events you already have. Build one today and it shows last week too, and How to find where users drop off covers how to read it.

Final thoughts

Adding analytics to a v0 app takes seven steps:

  1. Get your client key
  2. Ask v0 to add the script to your layout
  3. Allow your app's domains
  4. Publish and check it works
  5. Tag the clicks that matter
  6. Identify people when they sign in
  7. Build your first funnel

If your app takes payments through v0's Stripe integration, connect Stripe in Settings → Revenue and each payment is credited to the channel that brought the buyer. How to see which marketing channel earned each Stripe payment has the checkout code.

Building with another tool? How to add analytics to a vibe-coded app covers Lovable, Bolt, Replit, Base44 and v0 side by side.

See your own numbers today.

Free up to 1M events a month · no credit card

Contact

Tell us what you need.

A real person reads these. We usually reply within one working day.

Or email us directly at contact@spreelytics.com.