# Install the Revnu Tag

> One script tag that tells Revnu where your visitors come from, including ChatGPT, Perplexity and other AI assistants, search engines and ads.

Canonical: https://revnu.com/docs/revnu-tag

The Revnu Tag is a small first-party script for your site. On every visit it records where the visitor came from: an AI assistant (ChatGPT, Perplexity, Claude, Gemini, Copilot, Grok), a search engine, an ad click, another site, or a direct visit. Pair it with the [Event API](/docs/event-api) to tie signups, bookings and payments back to that source.

## The tag

```html
<script async src="https://revnu.com/v1.js" data-site="rk_..."></script>
```

Your site key starts with `rk_`. Revnu gives it to you when measurement is set up for your account; ask your Revnu contact if you don't have one. Install the tag once, on every page.

## Plain HTML

Paste the line into the `<head>` of your shared layout or template. Site builders work the same way:

- **WordPress:** your theme's header, or a header-scripts plugin.
- **Webflow:** Project Settings → Custom Code → Head Code.
- **Framer:** Site Settings → Custom Code → Start of `<head>`.

## Google Tag Manager

1. **Tags → New → Custom HTML**, and paste the line.
2. Set the trigger to **All Pages**.
3. Save, then **Submit** to publish the container.

Use Tag Manager or a hard-coded tag, not both.

## Next.js and Vercel

Add it to your root layout with `next/script`:

```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://revnu.com/v1.js" data-site="rk_..." strategy="afterInteractive" />
      </body>
    </html>
  );
}
```

On the Pages Router, put the same `<Script>` in `pages/_app.tsx`. Vercel needs nothing extra: the tag runs in the browser, so it works on any host.

## Check that it works

1. Open your site with a test source: `https://yoursite.com/?utm_source=chatgpt`.
2. In the browser console, run `revnu.getContext()`. You should see your site key, an `anonymousId` starting with `ra_`, and `attribution.trafficClass` set to `"ai_referral"`.
3. In the Network tab, filter for `collect`. You should see two requests to `revnu.com/api/measurement/collect`: `tag_loaded` and `page_seen`.

Revnu marks the tag as verified the first time it loads.

## Consent

By default the tag starts as soon as it loads. If your site asks visitors for consent first, add `data-consent="pending"` and pass on the answer from your consent manager once the tag has loaded:

```js
window.revnu?.consent("granted"); // or "denied"
```

While consent is pending or denied, the tag sets no cookies and sends nothing.

## Frequently asked questions

### Does the Revnu Tag see AI crawlers like GPTBot?

No. Crawlers do not run JavaScript. The tag sees people who click through to your site from an AI assistant's answer, which is the traffic that can turn into customers.

### How does it know a visit came from ChatGPT?

From the page that sent the visitor (chatgpt.com, perplexity.ai, claude.ai, gemini.google.com, copilot.microsoft.com, grok.com) or from a `utm_source` such as `chatgpt` or `perplexity`. Search engines and ad clicks are recognised the same way, from the referrer, UTM tags and ad click ids.

### What does it store?

Two first-party cookies, each mirrored in local storage: `revnu_aid`, a random visitor id (the cookie is renewed for a year on each visit; the local-storage copy does not expire), and `revnu_attr`, where the visit came from, kept for the attribution window (30 days by default). A session id lives in session storage. Page URLs are stored without their query string; only UTM tags and ad click ids are kept from it. The tag never reads form fields, names or email addresses.

### Will it slow my site down?

No. It is about 20 KB, loads with `async` so it never blocks rendering, and sends two small requests per page.
