Where Setup Lives
AI Traffic setup now lives inside Project Settings > AI Traffic. To generate the snippet:- Open your project
- Go to Project Settings
- Open the AI Traffic tab
- Click Generate Tracking Snippet
Install the Snippet
Copy the snippet and add it to your website’s layout or template file so it loads on every page. The snippet should be placed before the closing</body> tag.
GitBook
If your documentation is hosted on GitBook, you can use the official DevTune integration instead of manually installing the snippet:- Go to your GitBook space settings
- Navigate to Integrations
- Find and install the DevTune integration from the marketplace
- Enter your project snippet key when prompted
Next.js
Add the snippet to your root layout file (app/layout.tsx or pages/_document.tsx):
WordPress
Add the snippet to your theme’sfooter.php file, or use a plugin such as “Insert Headers and Footers” to add it to the footer section.
Webflow / Squarespace
Go to Site Settings, then Custom Code, and paste the snippet in the Footer section.Plain HTML
Add a<script> tag before the closing </body> tag in your HTML template:
Enable or Disable Tracking
On the Project Settings AI Traffic tab, use the toggle switch to enable or disable tracking at any time. When disabled, incoming events are rejected and no new data is recorded.Rate Limits
Each tracking snippet is rate-limited to 1,000 requests per minute. This is enough for most sites. If your site exceeds this limit, excess requests are silently dropped.Crawler Sensor Capabilities
AI crawlers and answer fetchers often do not run JavaScript, so DevTune also supports server-side crawler sensors. Use one server-side crawler sensor per hostname to avoid double-counting.| Capability | Cloudflare pull | Edge middleware |
|---|---|---|
| Best for | Hostnames already proxied by Cloudflare, including docs or static hosts that cannot run app middleware. | Vercel, Next.js, or self-hosted apps where request middleware can run. |
| Setup | Zone ID, readonly API token, and an orange-cloud proxied hostname. | Server-side ingest key plus @devtune/ai-traffic in your proxy or middleware. |
| Data flow | DevTune pulls hourly Cloudflare analytics buckets. | Your edge code pushes matched AI bot requests asynchronously. |
| Freshness | Hourly sync after Cloudflare analytics are available. | Near real-time push into DevTune’s ingest queue. |
| Granularity | Hourly aggregate buckets by page, user agent, bot class, and status. | One event per matched request with URL, path, user agent, bot class, and optional status. |
| History | Can backfill the recent Cloudflare analytics window available to the zone. | Starts collecting only after middleware is installed and deployed. |
| Status codes | Real edge status classes for proxied traffic, including 404s. | Known for redirects and denials returned by middleware. Normal page responses are status unknown unless you add route wrappers or known 404 path patterns. |
| Coverage | Only traffic that passes through the orange-cloud hostname. | Only routes reached by your app middleware. |
| Avoid | Using Cloudflare and middleware on the same hostname. | Double-proxying an app through Cloudflare just to collect traffic. |
- Use Cloudflare pull for docs, marketing, or static hostnames that already sit behind Cloudflare.
- Use edge middleware for Vercel, Next.js, and app hostnames where you do not want a Cloudflare-to-app double proxy.
- Keep a hostname on one crawler sensor at a time. If you move a hostname from Cloudflare pull to middleware, remove or pause the Cloudflare hostname connection.
Edge Middleware Setup
Install@devtune/ai-traffic, keep your ingest key in a server-side environment variable, and call the package only for likely machine user agents. Keep the prefilter broad enough for future crawler and fetcher names; the package still performs the authoritative registry match before ingesting an event, but the cheap prefilter keeps normal browser traffic out of the middleware tracking path. Set batchSize: 1, flushIntervalMs: 0, and waitUntilRegistryRefresh: false in middleware so background ingest work is scheduled immediately, and hourly registry refreshes do not extend middleware waitUntil duration.
response.status instead of null. For normal pass-through page requests, keep null because the middleware cannot observe the final page status.
Proxy Setup
You can proxy the tracking endpoint through your own domain when you need first-party routing for your deployment setup. Teams should still honor consent requirements and local privacy rules before collecting traffic data.How It Works
Instead of the snippet sending data tohttps://devtune.ai/api/v1/llm-traffic/collect, you configure a reverse proxy, so requests go to a path on your own domain.
Vercel / Next.js
Add a rewrite tonext.config.ts:
Netlify
Add tonetlify.toml:
Cloudflare
Create a redirect rule or Worker that proxies/dt/* to https://devtune.ai/api/v1/llm-traffic/*.
nginx
Multi-Site Tracking
You can use the same tracking snippet across multiple websites or subdomains. The dashboard automatically detects distinct domains and provides a domain filter so you can view traffic for each site individually or in aggregate.Verifying Installation
After installing the snippet:- Visit your website in a browser
- Open the DevTune AI Traffic dashboard
- You should see traffic appearing within a few minutes
- The snippet is present in your page source
- The snippet key matches the one shown in Project Settings
- Ad blockers are not blocking the request
- Tracking is enabled on the AI Traffic tab
Next Steps
- AI Traffic Dashboard - Explore your traffic data
- AI Traffic Overview - Learn what gets tracked and why