---
title: Cloudflare
description: Count AI bot visits from Cloudflare's HTTP request analytics with a read-only API token. Works on every Cloudflare plan.
---

Sommet reads the request counts of your zone from Cloudflare's GraphQL Analytics API. It only asks for requests whose user agent matches an [AI bot](/docs/ai-bots#bots-sommet-counts). It needs no Worker, no Logpush job and no change to your site. It works on the Free plan.

:::warning
Your DNS record must be **Proxied** (orange cloud). A DNS-only record sends traffic straight to your host, so Cloudflare never sees the requests.
:::

## Connect

1. **Copy the zone ID**

    In the Cloudflare dashboard, open your domain. On the **Overview** page, find the **API** section at the bottom of the right column and copy the **Zone ID**. It has 32 characters.

2. **Create a read-only API token**

    Open **My Profile → API Tokens → Create Token** and choose **Create Custom Token**.

    - **Token name:** `Sommet analytics`
    - **Permissions:** `Zone` · `Analytics` · `Read`
    - **Zone resources:** `Include` · `Specific zone` · your domain

    Select **Continue to summary**, then **Create Token**, and copy the token. Cloudflare shows it only once.

    You can also start from Cloudflare's [Zone Analytics token template](https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22analytics%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Zone%20Analytics%20Token). Limit it to your zone before you create it.

3. **Paste both in Sommet**

    Open **Settings → AI bot visits**, choose **Cloudflare**, paste the zone ID and the token, then select **Connect Cloudflare**.

    Sommet runs one real analytics query before it saves the token. If the query fails, the error from Cloudflare shows under the form.

## How the sync works

- Sommet checks for new data every 15 minutes and counts each full hour once.
- It waits 10 minutes after the end of an hour, because Cloudflare analytics arrive with a short delay.
- The first sync counts the last 24 hours.
- If the token stops working for more than 24 hours, the hours in between are skipped, not estimated.

## Troubleshooting

| Message                            | What to do                                                              |
| ---------------------------------- | ----------------------------------------------------------------------- |
| Cloudflare rejected this API token | The token is wrong, expired or revoked. Create a new one.               |
| Zone not found for this token      | The zone ID is wrong, or the token does not include this zone.          |
| The last sync failed               | Open **Change source**, read the error and paste a new token if needed. |

The token is encrypted at rest. Disconnecting the source deletes it. You can also revoke it in Cloudflare at any time.
