← All docs
Setup Guide

Bot traffic tracking setup

Install one package, add one line to your server, and see which AI assistants and crawlers read your site - ChatGPT, Claude, Perplexity, Googlebot, and ~30 more. Setup takes about five minutes.

Why this runs on your server: AI crawlers don't execute JavaScript, so browser analytics (GA4, Plausible) never see them. Server-side tracking catches every request. Reports are sent in the background and never slow your pages; human visitors are never stored.

1Get your tracking token

Create a free account, add your website, and open Dashboard → Track → Bot Traffic. Your site's tracking token is shown in the setup card.

2Install the package

npm install @didyouseo/bot-traffic

Zero dependencies, TypeScript types included, works on Node 18+ and edge runtimes.

3Add one line to your server

Next.js

// middleware.ts (or proxy.ts in newer Next.js)
import { NextResponse, type NextFetchEvent, type NextRequest } from "next/server";
import { trackBotVisit } from "@didyouseo/bot-traffic";

export function middleware(request: NextRequest, event: NextFetchEvent) {
  trackBotVisit(request, event, { token: process.env.DIDYOUSEO_TOKEN! });
  return NextResponse.next(); // or the rest of your existing middleware
}

export const config = {
  // Keep robots.txt, llms.txt, and sitemaps reachable - AI crawlers read those first
  matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};

Cloudflare Pages

// functions/_middleware.ts
import { trackBotVisit } from "@didyouseo/bot-traffic";

export async function onRequest(context) {
  trackBotVisit(context.request, context, { token: "YOUR_TRACKING_TOKEN" });
  return context.next();
}

Cloudflare Workers

import { trackBotResponse } from "@didyouseo/bot-traffic";

export default {
  async fetch(request, env, ctx) {
    const response = await handleRequest(request);
    // Response-aware: also records the HTTP status (404s are a content signal)
    trackBotResponse(request, response, ctx, { token: env.DIDYOUSEO_TOKEN });
    return response;
  },
};

Express / Connect

import { botTraffic } from "@didyouseo/bot-traffic/express";

app.use(botTraffic({ token: process.env.DIDYOUSEO_TOKEN }));

Hono

import { trackBotResponse } from "@didyouseo/bot-traffic";

app.use("*", async (c, next) => {
  await next();
  trackBotResponse(c.req.raw, c.res, c.executionCtx, { token: "YOUR_TRACKING_TOKEN" });
});

Any other stack

POST the same JSON from anywhere - see the API reference for the raw endpoint contract:

POST https://didyouseo.com/api/bot-traffic
Content-Type: application/json

{ "token": "...", "path": "/pricing", "userAgent": "GPTBot/1.2",
  "ip": "203.0.113.7", "status": 200 }

4Deploy and verify

Deploy, then send a test request pretending to be a bot:

curl -A "GPTBot/1.0" https://yourdomain.com/ -o /dev/null

Within a few seconds the visit appears in Track → Bot Traffic with a GPTBot badge. From then on, every real crawler visit is recorded automatically.

Frequently asked questions

Why can't Google Analytics see AI crawlers?+

AI crawlers like GPTBot, ClaudeBot, and PerplexityBot request your pages' raw HTML but never execute JavaScript. Analytics tools that rely on a browser script (GA4, Plausible, Fathom) therefore never see them. Bot traffic must be detected server-side, where every request passes through.

Will the tracking snippet slow down my website?+

No. The report is sent in the background (via waitUntil on edge runtimes, or after the response on Node servers), is capped at a 2-second timeout, and swallows every error. Human visitors never trigger a report at all - a cheap user-agent pre-filter runs first.

Do you store my human visitors' data?+

No. The package only forwards requests whose user-agent looks like a bot, and DidYouSEO's server discards anything it can't match to a known crawler. Human traffic is never stored.

Which bots does DidYouSEO detect?+

Around 30 known crawlers across six categories: AI answers (ChatGPT-User), AI search (PerplexityBot, OAI-SearchBot), AI training (GPTBot, ClaudeBot, Bytespider, CCBot), search indexing (Googlebot, Bingbot), SEO tools (AhrefsBot, SemrushBot), and link previews (Slack, Facebook). The list lives on our servers, so new bots are detected without you upgrading the package.

How does impostor detection work?+

If you forward the visitor's IP, DidYouSEO verifies Google, Bing, and Apple crawler IPs via reverse DNS. A request claiming to be Googlebot from an unverified IP is flagged so you can spot scrapers hiding behind famous bot names.

See who's reading your site

Bot traffic tracking is included on every plan - free accounts see the last 3 days, paid plans keep full history.

Related: what llms.txt does for AI visibility · pricing