@aranx/ai-analytics package wraps the Worker fetch handler. It records
requests from AI bots such as ChatGPT-User and PerplexityBot, and visits
from people who open your site from a link in an AI app. It sends events with
ctx.waitUntil, after the response.
If your site runs on Hono, use the Hono guide. If it is
a Shopify Hydrogen storefront, use the Shopify Hydrogen
guide.
Before you start
- In Aranx, open AI Visibility for the website and create a server key. Aranx shows the key once.
Setup
1
Install the package
2
Add the key as a secret
wrangler dev, add it to
.dev.vars:.dev.vars
3
Wrap the fetch handler
src/index.ts
ARANX_TRAFFIC_KEY binding, and the
client IP from CF-Connecting-IP, which Cloudflare sets. Keep the
other handlers (scheduled, queue) as they are.4
Deploy
Check the setup
Send a request with an AI user agent:What the package sends
For each AI request: the page URL without its query (it keepsutm_source),
the user agent, the response status, and the time. Bot visits also carry the
client IP, which Aranx checks against the bot’s published IP ranges and does
not store. Tracking never throws and never delays the response.
