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

# Connect Cloudflare for crawler analytics

> Send crawler request data from Cloudflare to Trackbase with a Worker on any plan, or with Logpush on Enterprise. Follow the setup steps.

If your website is behind Cloudflare, Cloudflare sees every request before it reaches your server, including requests from AI crawlers. Trackbase can receive that data in two ways: a Worker, which works on any Cloudflare plan, or Logpush, which needs a Cloudflare Enterprise plan. Both feed [crawler analytics](https://academy.trackbase.ai/crawler-analytics.md).

You find the values you need in Trackbase under **Settings**, in the crawler analytics card. Each method has its own tab with its own token.

> [tab] Workers
>
> **1. Generate a token**
>
> In the **Workers** tab in Trackbase, generate a token. Keep the ingest endpoint and the code snippet from the same tab at hand.
>
> **2. Create a Worker**
>
> In the Cloudflare dashboard, go to **Workers & Pages** and create a Worker.
>
> **3. Add the code**
>
> Replace the default code with the snippet from Trackbase.
>
> **4. Add the environment variables**
>
> Add `TRACKBASE_ENDPOINT` and `TRACKBASE_WORKER_TOKEN` with the values from Trackbase.
>
> **5. Add a route**
>
> Add a route trigger for your domain, for example `example.com/*`.
>
> **6. Deploy**
>
> Deploy the Worker.

> [tab] Logpush
>
> **1. Generate a token**
>
> In the **Logpush** tab in Trackbase, generate a token. Keep the destination URL and the custom header from the same tab at hand.
>
> **2. Create a Logpush job**
>
> In the Cloudflare dashboard, go to **Analytics & Logs → Logpush** and create a job with destination **Custom HTTP**.
>
> **3. Select the dataset**
>
> Select the dataset **HTTP Requests**.
>
> **4. Select the fields**
>
> Select these fields: `EdgeStartTimestamp`, `ClientIP`, `ClientRequestUserAgent`, `ClientRequestHost`, `ClientRequestPath`, `ClientRequestMethod`, `EdgeResponseStatus`, `EdgeResponseContentType`, `EdgeResponseBytes`.
>
> **5. Set the destination**
>
> Set the destination URL to the URL shown in Trackbase and add the custom header shown there.

## Check that data arrives

Open the **Crawlers** page in Trackbase. After connecting it shows that it is waiting for the first data, and it switches to the full view once the first crawler requests have come in.

> [!WARNING]
>
> Regenerating a token invalidates the old one. Update the Worker variable or the Logpush header afterwards. The Logpush token is also used by the WordPress plugin.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.