Monitor AI crawler traffic in your Next.js app
Track every time a known AI bot crawls your site. Lightweight middleware, zero dependencies beyond Next.js, 5-minute setup. Free for all CLICON clients.
What is bot tracking?
AI crawlers from Anthropic, OpenAI, Perplexity, Google, and others now regularly scan the web. Knowing when and what they crawl on your site is critical infrastructure for the agentic era.
The CLICON bot tracking middleware detects 9 known AI bots by User-Agent and reports each hit to your Lotus dashboard in real time. No performance impact, no client-side JavaScript, no extra dependencies.
9 bots detected
The middleware matches User-Agent headers against these known AI crawlers using case-insensitive regex patterns:
Installation
Three steps. Five minutes. No new dependencies.
Set LOTUS_TRACKING_KEY in Vercel
Add the environment variable LOTUS_TRACKING_KEY to your Vercel project. You can find your key in the Lotus admin panel under Settings → API Keys. The middleware uses this key to authenticate tracking requests to the Lotus API.
Add the middleware to your Next.js project
Copy this file to middleware.ts at the root of your Next.js project. This single file handles both bot detection and i18n routing. If you already have a middleware, merge the bot detection block into yours — it runs before your existing logic.
Add LOTUS_TRACKING_KEY to env.d.ts (TypeScript only)
If you use TypeScript, declare the env variable so Next.js picks it up. Add it to your env.d.ts or next-env.d.ts declarations. This step is optional but recommended for type safety.
Verify it works
Deploy your app and run this curl command from your terminal. It simulates a PerplexityBot request to your production domain:
You should see a 200 response. Check your Lotus dashboard — the hit will appear under Bot Traffic within seconds. If you get a different status code, check the troubleshooting section below.
Common issues
Middleware isn't firing
LOTUS_TRACKING_KEY is undefined
Bot hits not showing in dashboard
Getting 401 from tracking endpoint
Need help?
If you run into issues or need a tracking key, reach out at martin@clicon.app.