# Install on Lovable

> Add Reveata to an app built with Lovable (TanStack Start or Vite), serve it from your own subdomain, and credit payments to their visits.

Lovable apps render every page from one root file, so the snippet goes there once. Which file depends on when the app was created:

- **Apps created from May 2026** use TanStack Start. The page shell is in `src/routes/__root.tsx`.
- **Older apps** use React with Vite. Every page loads from `index.html` at the root of the project.

Copy the snippet from your Reveata dashboard (it contains your website’s tracking id):

```html
<script
  defer
  data-website-id="ws_your_tracking_id"
  src="https://reveata.com/js/script.js"
></script>
```

## Add it to your app

The simplest way is to ask Lovable in the chat:

> Add this script tag exactly as written to the `<head>` of every page. If the app has `src/routes/__root.tsx`, put it inside `<head>` in the root document component, after `<HeadContent />`, as JSX. Otherwise put it before `</head>` in `index.html`. Don’t bundle it, don’t change its attributes, and change nothing else: (paste the snippet)

Or edit the file yourself, in Lovable’s code editor (on paid plans) or in the GitHub repository connected to the project.

In `src/routes/__root.tsx` (TanStack Start), the tag is JSX inside the document’s `<head>`:

```tsx
<head>
  <HeadContent />
  <script defer data-website-id="ws_your_tracking_id" src="https://reveata.com/js/script.js"></script>
</head>
```

In `index.html` (Vite), paste the snippet before `</head>`.

Then **Publish**, or **Publish → Update** if the app is already published: the live app is a snapshot and doesn’t change until you update it. In Reveata, add the website with the address visitors use: your custom domain, or your `.lovable.app` address. Visits to the editor preview are on another address and are not counted.

Page changes in the app go through the browser’s History API, which the script follows, so every page is counted.

## Serve it from your own subdomain

With a custom domain, use the [managed proxy](https://reveata.com/docs/managed-proxy): add one DNS record (for example `stats.example.com`) where your domain’s DNS is managed, and replace the snippet with the new one Reveata gives you. No code runs on Lovable for it.

## Revenue

Depending on how your app takes payments:

- **Your own Stripe account** (Lovable’s Stripe integration, with your secret key). The checkout runs in edge functions in your project, which Lovable can change. Connect the same Stripe account in Reveata under **Settings → Payments**, then paste the prompt from [Revenue in apps built with AI](https://reveata.com/docs/revenue-ai-builders) into the Lovable chat. It adds the Reveata visitor id to the checkout metadata, so each payment is credited to the visit that brought the buyer.
- **Lovable’s built-in payments.** If Lovable set up a Stripe account for you, connect it in Reveata once you have claimed it and can sign in to it. The built-in checkout can’t be changed, so payments are credited by email: ask Lovable to call `window.reveata?.('identify', { userId: user.id, email: user.email })` after sign-in.

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

## Check it works

1. Open your published app in a normal browser window with ad blockers turned off for it.
2. Open **Realtime** in Reveata: your visit appears within a few seconds.
3. If it doesn’t, view the page source of the published app and search for `data-website-id`, then follow [Verify your installation](https://reveata.com/docs/verify-your-installation).

## Goals

Add `data-reveata-goal="signup"` to a button or link, or call `window.reveata?.('goal', 'signup')` once a signup succeeds. You can ask Lovable to do either. See [Custom goals](https://reveata.com/docs/custom-goals).

## Common pitfalls

- **Not updated.** Code changes reach the live app only after **Publish → Update**.
- **Testing in the preview.** The editor preview is another address; test the published app.
- **The tag was rewritten.** If Lovable turned the snippet into an import or a `useEffect`, its `data-website-id` can get lost. Ask it to keep the plain `<script>` tag exactly as written.
- **Two payment setups.** Lovable’s built-in payments and your own Stripe integration can’t be used together; connect in Reveata the one your app uses.
