/docs/site-owner-worker-install
For site owners

Site-owner worker install

Optional worker for verified site owners. It reports AI agent visits to Lyrenth from your CDN edge (GPTBot, ClaudeBot, PerplexityBot, and the rest), so Lyrenth sees the full picture of who's reading your site, not just the agents that route through our API. Install at your CDN edge in 5-10 minutes.

Hard contract

The worker is a transparent pass-through. It forwards every request to your origin unmodified, observes the User-Agent in the background via waitUntil(), and ships aggregated counts to Lyrenth on a 30-second batched flush. A Lyrenthoutage looks like "no new bot data appears in my dashboard," never "my site is down."

01

Verify your domain on Lyrenth

If you haven't already, go to /sites/add and verify the domain via DNS TXT or .well-known. The ingest token is auto-minted on successful verify; you'll need it for the worker.
02

Get your ingest token

Go to /sites/<your-domain>/settings on the Lyrenth dashboard. The token is in the "Ingest token" panel; click the eye icon to reveal it, then the copy button. Looks like aiwt_ followed by 32 hex characters. Keep it private; rotate from the same panel if it ever leaks.
03

Pick the integration that matches your host

Two parallel templates ship with the same wire protocol; pick one based on where your site lives.

Cloudflare Worker

Sites on Cloudflare (any origin host)

Pros
  • Captures HTTP response status code (404 / 5xx breakdowns work)
  • Independent of customer's framework
  • Cron trigger option for quiet sites
Trade-offs
  • Requires a Cloudflare account + wrangler CLI
Jump to install steps →

Vercel Edge Middleware

Sites on Vercel running Next.js

Pros
  • Drops into your existing project root
  • Deploy via git push, no CLI tooling
  • Env vars set in Vercel project settings
Trade-offs
  • Doesn't observe response status (middleware fires before route renders)
  • Requires a Next.js project
Jump to install steps →
Path A

Cloudflare Worker

For sites with DNS on Cloudflare. The worker proxies every request at the CF edge before it reaches your origin.

A1

Get the template

Clone or copy integrations/cloudflare-worker/ from the Lyrenth repo (or build your own following the same shape). The directory includes worker.js, a wrangler.toml template, and a README with the local-dev workflow.
A2

Customize wrangler.toml

Replace the placeholder domain and routes with yours:
name = "lyrenth-bot-traffic"
main = "worker.js"
compatibility_date = "2026-05-09"

[vars]
LYRENTH_DOMAIN = "your-domain.com"

routes = [
    { pattern = "your-domain.com/*", zone_name = "your-domain.com" },
    { pattern = "*.your-domain.com/*", zone_name = "your-domain.com" },
]

The two route patterns cover the apex and any subdomain. If you only want bot tracking on a specific subdomain, narrow the routes accordingly.

A3

Set the ingest token as a secret

Don't put it in wrangler.toml(it's in your git history). Use Cloudflare's secret management:
wrangler login
wrangler secret put LYRENTH_INGEST_TOKEN
# Paste the aiwt_... token when prompted
A4

Deploy

wrangler deploy

Within minutes, traffic to your domain flows through the worker. Tail logs in real time with wrangler tailif something doesn't look right.

Path B

Vercel Edge Middleware

For sites already on Vercel running Next.js. The middleware lives inside your existing project and deploys on the next git push.

B1

Copy the template

Copy integrations/vercel-edge/middleware.ts from the Lyrenth repo to your project root (or src/middleware.ts if you have a src/ layout).

Already have a middleware.ts? See Path B in the integration README; it walks through pulling our helpers into lib/lyrenth-ingest.ts and invoking from your existing middleware.

B2

Set env vars in Vercel

Vercel project Settings → Environment Variables. Add three values; mark the token as a secret:
LYRENTH_DOMAIN=your-domain.com
LYRENTH_INGEST_TOKEN=aiwt_<your-token>
# optional, only if running self-hosted Lyrenth:
# LYRENTH_INGEST_URL=https://www.lyrenth.com

Apply to all environments (Production, Preview, Development) so middleware works on every deployment.

B3

Push

git add middleware.ts
git commit -m "add lyrenth bot-traffic middleware"
git push

Vercel auto-deploys. Within minutes, real bot traffic to your site flows into Lyrenth's internal view, used to round out the picture of who's reading your content.

Verify it's working

Hit your site with a bot User-Agent from any machine, then check the dashboard.

curl -A "Mozilla/5.0 (compatible; GPTBot/1.0)" \
  https://your-domain.com/

Within 30 seconds the ingest endpoint records the bot visit (bot_name="gptbot", category="ai_crawler"). The data feeds Lyrenth's internal view of who's reading your site; it doesn't change anything in your dashboard view.

Privacy

What the worker observes

  • Request User-Agent string (sent to Lyrenth)
  • Request path (query string stripped)
  • Response status code (Cloudflare worker only)

What it does NOT observe

  • Request body / form data
  • Response body
  • User cookies or auth tokens
  • Visitor IP addresses
  • Browser fingerprints

Path query strings are stripped client-side at the worker AND again server-side as defense in depth, since query parameters often carry session tokens, search terms, or PII. If your privacy policy specifies what edge processing happens for visitors, you should disclose this worker's existence and the categories above.

Get the ingest token first

Verify your domain on Lyrenth, then grab the token from the domain's settings page.