The site-owner worker
An optional edge worker for verified domain owners. It reports AI agent visits from your CDN edge to Lyrenth, so your dashboard sees the full picture of who is reading your site, not just agents that route through our API. Two templates: Cloudflare and Vercel.
Known AI agents
Matches incoming User-Agents against a maintained list of AI crawlers and assistants.
Edge, not origin
Fires a non-blocking beacon from the edge. Zero added latency for your visitors.
No user PII
Only the bot User-Agent, path, time bucket, and count. No human visitor data is collected.
Verify your domain and get the ingest token
You must have a verified domain first. Verify at /sites/add, then generate the ingest token in your site's settings. It starts with aiwt_ and only works for your own domain, so a leaked token cannot report for anyone else.
Cloudflare Worker
Deploy this Worker route in front of your zone, with your domain in the URL and the token in the LYRENTH_INGEST_TOKEN secret. It reports AI-agent requests to Lyrenth and passes everything else straight through.
export default {
async fetch(req, env, ctx) {
const ua = req.headers.get("user-agent") || "";
if (/GPTBot|ClaudeBot|AIWebIndex|PerplexityBot/i.test(ua)) {
ctx.waitUntil(fetch("https://api.lyrenth.com/v1/ingest/bot/YOUR-DOMAIN.com", {
method: "POST",
headers: {
"Authorization": `Bearer ${env.LYRENTH_INGEST_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
events: [{
raw_ua: ua,
path: new URL(req.url).pathname,
bucket_at: new Date().toISOString(),
count: 1,
}],
}),
}));
}
return fetch(req); // pass through, never block
},
};Vercel Middleware
Drop this into middleware.ts at your project root. Same beacon, same non-blocking behavior.
import { NextResponse } from "next/server";
export function middleware(req) {
const ua = req.headers.get("user-agent") || "";
if (/GPTBot|ClaudeBot|AIWebIndex|PerplexityBot/i.test(ua)) {
fetch("https://api.lyrenth.com/v1/ingest/bot/YOUR-DOMAIN.com", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LYRENTH_INGEST_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
events: [{
raw_ua: ua,
path: req.nextUrl.pathname,
bucket_at: new Date().toISOString(),
count: 1,
}],
}),
}); // fire-and-forget
}
return NextResponse.next();
}Watch the data land
Within a minute, AI-visit data appears under the Bot traffic panel of your site in the dashboard, broken down by agent, path, and time. Pair it with the index-side reads Lyrenth already tracks for the complete view. High-traffic sites can batch: one POST accepts up to 1,000 events, so a worker may collect visits for around 30 seconds and send them together.