> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withgauge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring AI Traffic

> Connect Cloudflare or Vercel logs to Gauge to power the AI Traffic page.

## Configuring AI Traffic

[AI Traffic](/navigating/ai-traffic) is powered by your server logs. Forward them to Gauge from one of two sources:

* **Vercel** — requires a Vercel **Pro or Enterprise** plan. Use this if you host on Vercel without Cloudflare in front.
* **Cloudflare** — works on any Cloudflare plan, including Free. Use this if your site is behind Cloudflare, even if the origin is hosted elsewhere.

Both live under **Settings → Integrations**, on the **Vercel** and **Cloudflare** cards. You can connect both.

## Your Drain URL and Secret

Every setup path uses two values shown on the integration page:

* **Destination URL** (called **Endpoint URL** on the Vercel card) — where your host sends logs. Click **Copy**.
* **Secret** — authenticates those logs. Click **Show**, then **Copy**.

## Vercel Setup

Open **Settings → Integrations → Vercel** in Gauge — you'll copy the Endpoint URL and secret from it. The rest happens in the Vercel dashboard:

1. In your Vercel team, open **Settings → Drains** and click **Create Drain**.
2. Pick **Logs** as the data source.
3. Select the projects you want to track. Under source types, enable **Static Files**, **Function**, and **Edge Function** — all three together capture every incoming HTTP request. Under environments, enable **Production**.
4. For the destination, choose **Custom endpoint** and paste the **Endpoint URL** from the Gauge page. Pick either **JSON** or **NDJSON** as the format — Gauge accepts both.
5. Still on the destination step, click **Add header** and create a header named `Authorization` with the value `Bearer <your-secret>` — click **Show** on the Gauge page to reveal the secret.
6. Save the drain. Vercel runs a connectivity check, and traffic starts flowing within a few minutes. In Gauge, the card shows a **Receiving events** badge and a **View AI Traffic** button once events land.

{/* Screenshot: Vercel destination step with custom endpoint and Authorization header */}

<Warning>
  Without the `Authorization` header, Gauge rejects every event with a 403 and you'll see no traffic. The value must start with `Bearer ` followed by your secret.
</Warning>

## Cloudflare Setup

Open **Settings → Integrations → Cloudflare** and pick a tab:

* **Worker (any plan)** — Gauge forwards traffic through a small Cloudflare Worker. Right for almost everyone.
* **Logpush (Enterprise)** — Cloudflare streams logs directly to Gauge. Cloudflare Enterprise only.

### Option 1: Automatic Worker Setup (Recommended)

Gauge creates the Worker, uploads the secret, and attaches the routes. It needs a scoped Cloudflare API token:

1. Click **Connect Cloudflare**.
2. Click **Create the token on Cloudflare**. This opens Cloudflare's **Create Custom Token** form pre-filled with the three permissions Gauge needs: `Account.Workers Scripts: Edit`, `Zone.Workers Routes: Edit`, and `Zone.Zone: Read`.
3. In Cloudflare, click **Continue to summary**, then **Create Token**, and copy the token.
4. Back in Gauge, paste it into the **Paste the token** field and click **Connect**.
5. If the token can access more than one Cloudflare account, pick one and click **Use this account**.

{/* Screenshot: Cloudflare's Create Custom Token page, pre-filled */}

The card now shows a **Cloudflare connected** badge and lists every zone (domain) on your account under **Your zones**.

#### Enable a Zone

Click **Enable** on a zone. Gauge deploys the Worker with a wildcard route covering the whole zone and forwards every request.

To change what gets forwarded, expand the zone with the chevron first. Two settings:

**Routes** — which parts of your site the Worker watches:

* **Apex** (`yourdomain.com/*`)
* **WWW subdomain** (`www.yourdomain.com/*`)
* **Docs subdomain** (`docs.yourdomain.com/*`)
* **Wildcard** (`*.yourdomain.com/*`) — all subdomains
* **Add route** for a custom pattern, like `app.yourdomain.com/*`

**Traffic to forward:**

* **All requests (recommended)** — forward everything; Gauge classifies bots downstream.
* **Bot requests only** — drop human traffic at the edge, forward only known AI crawlers (GPTBot, ClaudeBot, PerplexityBot, etc.). Only use this if your security policy requires it — filtered traffic can't be backfilled.

Click **Enable** (or **Update** if the zone is already running).

#### Verify

The zone badge shows **Enabled, no events yet** right after deploying, then **Receiving events** once traffic lands — usually within a minute. If events never arrive, check that the zone's DNS records are proxied through Cloudflare (orange cloud on). The Worker only sees proxied traffic.

### Option 2: Manual Worker Setup

If you'd rather not give Gauge an API token, expand **Prefer to set up manually?** at the bottom of the Worker tab:

1. In the Cloudflare dashboard, go to **Workers & Pages → Create Application**, choose **Start with Hello World!**, and click **Deploy**.
2. Open the new Worker, go to **Settings → Variables and Secrets**, and add an encrypted **Secret** named `DRAIN_SECRET`. For the value, click **Show** on the Secret row in Gauge, copy it, paste it in, and select **Save Version**.
3. Click **Edit code**, replace the starter contents with the Worker code from the Gauge page (**Copy Worker code** button), and click **Save and deploy**.
4. Go to **Settings → Triggers → Routes** and add a route matching your zone — for example, `*.yourdomain.com/*`.
5. Traffic starts forwarding within a minute. Gauge shows **Manual setup detected** with per-zone event counts once payloads arrive.

### Option 3: Logpush (Cloudflare Enterprise)

1. In the Cloudflare dashboard, open your zone and add a **Logpush job** under **Analytics & Logs → Logs**.
2. Select dataset **HTTP requests** and destination **HTTP**.
3. Paste the **Destination URL** from the Gauge page.
4. Under **Advanced options**, add a header named `Authorization` with the value `Bearer <your-secret>`.
5. On the **Configure fields** step, select `ClientRequestUserAgent`. Also recommended: `EdgeStartTimestamp`, `ClientRequestPath`, `ClientRequestHost`, `EdgeResponseStatus`, `EdgeResponseBytes`, and `ClientCountry`.
6. Save the job. Cloudflare sends a test batch, and the badge in Gauge flips to **Receiving events** within a few minutes.

<Warning>
  If `ClientRequestUserAgent` isn't selected, the logs arrive without user agents and Gauge can't detect AI bots.
</Warning>

## Turning It Off

* **Vercel:** open **Settings → Drains** in Vercel, click into the drain, and select **Delete drain**.
* **Cloudflare (automatic):** click **Disable** on a zone, or **Disconnect** to drop the API token entirely.
* **Cloudflare (manual or Logpush):** delete the Worker route or Logpush job in the Cloudflare dashboard.

Historical data already in Gauge stays put.

## Troubleshooting

* **No events after Vercel setup** — check the `Authorization` header exists and starts with `Bearer `, and that **Production** is enabled under environments.
* **No events after Cloudflare Worker setup** — check the zone's DNS records are orange-cloud proxied and the route pattern matches your traffic (including the trailing `/*`).
* **Traffic stopped after regenerating the secret** — update the `DRAIN_SECRET` in your Worker, or the `Authorization` header in your Logpush job or Vercel drain, with the new value.
* **Bots missing from Logpush data** — make sure `ClientRequestUserAgent` is in the job's field list.

Still stuck? Email [support@withgauge.com](mailto:support@withgauge.com).
