# Install on v0

> Add Reveata to a Next.js app generated with Vercel v0.

v0 generates Next.js apps with the App Router, so the snippet goes in the root layout, `app/layout.tsx`, once. Next.js has a full guide in [Install on Next.js](https://reveata.com/docs/nextjs); this page covers doing it from v0.

## Add it to your app

Either ask v0 in the chat, for example:

> In `app/layout.tsx`, import `Script` from `next/script` and add this inside `<body>`, after `{children}`, exactly as written, changing nothing else:
>
> `<Script src="https://reveata.com/js/script.js" data-website-id="ws_your_tracking_id" strategy="afterInteractive" />`

Or edit `app/layout.tsx` yourself in v0’s code view, or in the GitHub repository connected to the project:

```tsx
// 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://reveata.com/js/script.js"
          data-website-id="ws_your_tracking_id"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}
```

Replace `ws_your_tracking_id` with the id from your Reveata dashboard. Then publish: the first **Publish** creates the Vercel project, and later changes go live with **Publish → Publish Changes** (or by merging the pull request, for projects connected to GitHub). In Reveata, add the website with the address visitors use: your custom domain, or the `.vercel.app` address of the production deployment. Previews on other addresses are not counted.

Client-side navigation between pages is counted by the script.

## Check it works

Open the deployed app in a private window, then check that the visit appears in your Reveata dashboard. If it doesn’t, follow [Verify your installation](https://reveata.com/docs/verify-your-installation).

## Goals

Ask v0 to add `data-reveata-goal="signup"` to your signup button, or to call `window.reveata?.('goal', 'signup')` once a signup succeeds. See [Custom goals](https://reveata.com/docs/custom-goals).

## Serve it from your own subdomain

Two options:

- **The managed proxy.** With a custom domain, add one DNS record (for example `stats.example.com`) and use the new snippet Reveata gives you. See [Managed proxy](https://reveata.com/docs/managed-proxy).
- **Rewrites in the app.** A v0 app is a Next.js app on Vercel, so it can proxy the script and events itself: see [Next.js](https://reveata.com/docs/self-hosted-proxy#next-js) and [Vercel](https://reveata.com/docs/self-hosted-proxy#vercel). Add the proxy secret as the `REVEATA_PROXY_SECRET` environment variable in the Vercel project.

## Revenue

v0 adds Stripe through the Vercel Marketplace: it starts as a Stripe sandbox, which you claim into a new or existing Stripe account for production. The checkout code is in your Next.js app.

1. Connect the live Stripe account in Reveata under **Settings → Payments** ([restricted key](https://reveata.com/docs/stripe-restricted-key) or [Connect with Stripe](https://reveata.com/docs/stripe-connect)).
2. Paste the prompt from [Revenue in apps built with AI](https://reveata.com/docs/revenue-ai-builders) into v0. It sends `window.reveata.metadata()` to the route or server action that creates the checkout and puts the visitor id in the checkout metadata. [Install on Next.js](https://reveata.com/docs/nextjs#link-payments-to-visits) shows the server side.

Other providers: [Connect a payment provider](https://reveata.com/docs/connect-a-payment-provider).

## Common pitfalls

- **Changes not published.** Edits in v0 reach the live app with **Publish Changes** (or the merged pull request).
- **Preview deployments.** They run on other `.vercel.app` addresses and are refused unless you add them under **Settings → General → Additional domains**. Leaving them out keeps testing out of your numbers.
- **The sandbox.** Payments in the Stripe sandbox are not imported from your live account. Claim the sandbox before you launch.
