AI bot tracker — install guide
The tracker is a small piece of code on your website that reports visits from AI crawlers — the bots OpenAI, Anthropic, Perplexity, Google, Meta and others use to train models and answer questions. Once installed, the Bot Traffic tab in your NeverDrafts dashboard shows which bots read your site, how often, and which pages.
Training
Bulk crawlers collecting your content to train AI models. Their visits mean your content can shape what future models know.
AI search index
Crawlers building the retrieval indexes behind AI search products. Being crawled here is a prerequisite for being cited.
Live answer fetch
Real-time fetches made while an assistant answers a specific user. These are the closest thing to an AI "pageview" of your site.
Good to know before you start
- —It can't slow your site down. The tracker only reacts to AI-bot visits and reports them in the background — human visitors are never delayed.
- —No visitor data, no cookies. Only requests whose User-Agent matches a known AI bot are reported. Human traffic is never recorded.
- —Your tracking key is safe to share. It can only report bot hits into your dashboard — it can't read anything. Find it in Dashboard → your monitor → Bot Traffic; the snippets below use
YOUR_TRACKING_KEYuntil you swap yours in. - —Server-side beats the HTML tag. Most AI crawlers never run JavaScript, so a plain HTML tag can't see them. If your platform allows server code (WordPress, Next.js) or your DNS is on Cloudflare, use those — they see every AI-bot request.
Which option should I pick?
| Your site runs on… | Install this | Coverage |
|---|---|---|
| WordPress (any host) | WordPress snippet (below) | Full |
| Next.js / Vercel | Middleware snippet (below) | Full |
| Shopify, Webflow, Framer, Wix, Squarespace… | HTML tag now; add the Cloudflare Worker if your DNS is on Cloudflare | Partial → Full with Cloudflare |
| Anything, with DNS on Cloudflare | Cloudflare Worker (below) | Full |
| Custom server (Node, PHP, Rails…) | Send your developer the brief at the bottom | Full |
Install instructions by platform
WordPress
Sees every AI-bot request — recommended.
- 1In your WordPress admin, install the free "WPCode" plugin (Plugins → Add New → search "WPCode"). It lets you add code without editing theme files.
- 2Go to Code Snippets → Add Snippet → "Add Your Custom Code", and pick "PHP Snippet".
- 3Paste the code below, name it "NeverDrafts AI bot tracker", set it to run "Everywhere", and click Save & Activate.
- 4Comfortable editing your theme instead? The same code can also go at the end of your child theme's functions.php.
// NeverDrafts AI bot tracker. // Reports visits from AI crawlers (GPTBot, ClaudeBot, PerplexityBot, ...) // to your NeverDrafts dashboard. Human visitors are never reported. add_action('init', function () { $ua = $_SERVER['HTTP_USER_AGENT'] ?? ''; if (!preg_match('/chatgpt-user|oai-searchbot|gptbot|claude-searchbot|claude-user|claudebot|claude-web|anthropic-ai|perplexitybot|perplexity-user|google-cloudvertexbot|googleother|meta-externalfetcher|meta-externalagent|facebookbot|applebot|amazonbot|microsoftpreview|mistralai-user|duckassistbot|bytespider|deepseekbot|ccbot|cohere-training-data-crawler|cohere-ai|ai2bot|youbot|diffbot|petalbot|pangubot|omgili|timpibot|img2dataset|neverdrafts-verify/i', $ua)) { return; // not an AI bot — do nothing } wp_remote_post('https://www.neverdrafts.com/api/track', array( 'blocking' => false, // fire-and-forget, never slows your site down 'headers' => array('Content-Type' => 'application/json'), 'body' => wp_json_encode(array( 'k' => 'YOUR_TRACKING_KEY', 'ua' => $ua, 'p' => $_SERVER['REQUEST_URI'] ?? '/', 'src' => 'server', )), )); });
💡 Works on any WordPress host. If your site sits behind a cache/CDN that serves pages without hitting PHP (some aggressive full-page caches), the Cloudflare option catches those too.
Next.js / Vercel
Sees every AI-bot request — recommended.
- 1Open middleware.ts at the root of your Next.js project (create it if it doesn't exist).
- 2Paste the code below inside your middleware function, before its return statement.
- 3Deploy. That's it — the tracker only acts on AI-bot user agents.
// NeverDrafts AI bot tracker. // Paste inside your existing middleware function, before the return. // (No middleware yet? Create middleware.ts at the project root with a // function that ends in "return NextResponse.next()" and put this in it.) const ua = request.headers.get('user-agent') || ''; if (/chatgpt-user|oai-searchbot|gptbot|claude-searchbot|claude-user|claudebot|claude-web|anthropic-ai|perplexitybot|perplexity-user|google-cloudvertexbot|googleother|meta-externalfetcher|meta-externalagent|facebookbot|applebot|amazonbot|microsoftpreview|mistralai-user|duckassistbot|bytespider|deepseekbot|ccbot|cohere-training-data-crawler|cohere-ai|ai2bot|youbot|diffbot|petalbot|pangubot|omgili|timpibot|img2dataset|neverdrafts-verify/i.test(ua)) { // fire-and-forget — only AI-bot requests are reported fetch('https://www.neverdrafts.com/api/track', { method: 'POST', body: JSON.stringify({ k: 'YOUR_TRACKING_KEY', ua, p: request.nextUrl.pathname, src: 'server', }), }).catch(() => {}); }
Cloudflare
Sees every AI-bot request. Works for any stack if your DNS runs through Cloudflare.
- 1In the Cloudflare dashboard, go to Workers & Pages → "Create an app" and choose "Start with Hello World!" (not a template, and not the static-file uploader — that one rejects .js files).
- 2Give the Worker a name (e.g. "neverdrafts-bot-tracker") and click Deploy — it ships Cloudflare's placeholder code first.
- 3On the deployed Worker, click "Edit code", delete the placeholder, paste the snippet below, and click Deploy again.
- 4Go to the Worker's Settings → Domains & Routes → Add → Route, and add routes covering your site — both yourdomain.com/* and www.yourdomain.com/* (your domain must be proxied through Cloudflare — the orange cloud in DNS).
// NeverDrafts AI bot tracker — Cloudflare Worker. // Deploy as a Worker and add a route covering your site (e.g. example.com/*). export default { async fetch(request, env, ctx) { const ua = request.headers.get('user-agent') || ''; if (/chatgpt-user|oai-searchbot|gptbot|claude-searchbot|claude-user|claudebot|claude-web|anthropic-ai|perplexitybot|perplexity-user|google-cloudvertexbot|googleother|meta-externalfetcher|meta-externalagent|facebookbot|applebot|amazonbot|microsoftpreview|mistralai-user|duckassistbot|bytespider|deepseekbot|ccbot|cohere-training-data-crawler|cohere-ai|ai2bot|youbot|diffbot|petalbot|pangubot|omgili|timpibot|img2dataset|neverdrafts-verify/i.test(ua)) { // reported in the background — the visitor is never delayed ctx.waitUntil( fetch('https://www.neverdrafts.com/api/track', { method: 'POST', body: JSON.stringify({ k: 'YOUR_TRACKING_KEY', ua, p: new URL(request.url).pathname, src: 'server', }), }), ); } return fetch(request); // pass every request through untouched }, };
💡 This is the best option for Shopify, Webflow, Framer, Squarespace or Wix sites when your domain's DNS is on Cloudflare — it sees bots those platforms' JS tag can't.
Shopify
Browser tag only — catches JS-running AI agents, not classic crawlers. Add Cloudflare for full coverage.
- 1In Shopify admin, go to Online Store → Themes → (your live theme) → ⋯ → Edit code.
- 2Open layout/theme.liquid.
- 3Paste the tag below just before the closing </head> tag and click Save.
<script async src="https://www.neverdrafts.com/nd-tracker.js" data-key="YOUR_TRACKING_KEY"></script>
💡 Shopify doesn't let apps run server-side on page requests, so the tag can only see AI agents that execute JavaScript. If your domain's DNS is on Cloudflare, add the Cloudflare Worker too for the full picture.
Webflow
Browser tag only — catches JS-running AI agents, not classic crawlers. Add Cloudflare for full coverage.
- 1In Webflow, open your site's Settings → Custom Code (paid site plan required for custom code).
- 2Paste the tag below into the "Head Code" box.
- 3Save and Publish the site.
<script async src="https://www.neverdrafts.com/nd-tracker.js" data-key="YOUR_TRACKING_KEY"></script>
Framer
Browser tag only — catches JS-running AI agents, not classic crawlers. Add Cloudflare for full coverage.
- 1In Framer, open Site Settings → General → Custom Code.
- 2Paste the tag below into "End of <head> tag".
- 3Save and Publish.
<script async src="https://www.neverdrafts.com/nd-tracker.js" data-key="YOUR_TRACKING_KEY"></script>
Any website
Browser tag only — catches JS-running AI agents, not classic crawlers.
- 1Open the HTML of your site (or your platform's "custom head code" setting — most site builders have one).
- 2Paste the tag below anywhere inside <head>, on every page you want tracked.
- 3Publish / deploy your site.
<script async src="https://www.neverdrafts.com/nd-tracker.js" data-key="YOUR_TRACKING_KEY"></script>
💡 If you control the server (Node, PHP, nginx+worker, etc.), a server-side install sees far more — send your developer the brief below and they'll know what to do.
Check it's working
1. The Verify button. On the Bot Traffic tab in your dashboard, click Verify installation. We fetch your homepage with a test marker; a working server-side install reports it back within seconds. It also detects the HTML tag.
2. A manual test. Anyone with a terminal can run:
curl -A "neverdrafts-verify" https://yoursite.comAfter that, real data simply takes time: AI crawlers visit on their own schedule. Most sites see the first genuine bot hits within hours to a couple of days.
Not technical? Send this to your developer
One message with everything they need — swap in your tracking key from the dashboard, and they never have to log into NeverDrafts.
Hi!
Could you install the NeverDrafts AI bot tracker on our website? It records visits from AI crawlers (GPTBot, ClaudeBot, PerplexityBot, etc.) so we can see how AI tools read our site. It only reports requests whose User-Agent matches a known AI bot — no human visitor data, no cookies, and the reporting call is fire-and-forget so it can't slow the site down.
Platform: Any website
Tracking key: YOUR_TRACKING_KEY
Endpoint: POST https://www.neverdrafts.com/api/track
Payload: JSON {"k": "<tracking key>", "ua": "<user agent>", "p": "<request path>", "src": "server"}
Install steps for Any website:
1. Open the HTML of your site (or your platform's "custom head code" setting — most site builders have one).
2. Paste the tag below anywhere inside <head>, on every page you want tracked.
3. Publish / deploy your site.
Code to install:
<script async src="https://www.neverdrafts.com/nd-tracker.js" data-key="YOUR_TRACKING_KEY"></script>
Note: on Any website this is the browser tag, which only sees AI agents that execute JavaScript. If our DNS is on Cloudflare, a tiny Worker gives full coverage instead — same endpoint and payload, just match the User-Agent server-side and POST the same JSON.
To confirm it works: once deployed, we'll click "Verify installation" in the NeverDrafts dashboard — it sends a test request with the User-Agent marker "neverdrafts-verify" to the site's homepage and checks it comes back. You can also test manually:
curl -A "neverdrafts-verify" https://our website
and the install is working if a hit shows up in our dashboard a few seconds later.
Thanks!No account yet? Start monitoring free — your tracking key is created with your first monitor.
