Track AI bot visits to your website with zero code changes.
This Cloudflare Worker intercepts requests to your site and:
- Detects 40+ AI bots - GPTBot, ClaudeBot, PerplexityBot, and more
- Tracks visits - Sends bot data to your AttractOS dashboard
- Injects badge (free tier) - Tamper-proof "Bot Traffic by AttractOS" badge
- Click the "Deploy to Cloudflare Workers" button above
- Log into your Cloudflare account
- Enter your AttractOS site key when prompted (find it at attractos.com/dashboard/settings)
- Click Deploy
- Configure a route to your domain in the Cloudflare dashboard
# Clone this repo
git clone https://github.com/aadilr/attractos-worker.git
cd attractos-worker
# Install dependencies
npm install
# Set your site key
wrangler secret put ATTRACTOS_KEY
# Deploy
npm run deploy| Variable | Required | Description |
|---|---|---|
ATTRACTOS_KEY |
Yes | Your site key from AttractOS dashboard |
ATTRACTOS_PLAN |
No | free (default) or pro - controls badge injection |
After deployment, configure routes in your Cloudflare dashboard:
- Go to Workers & Pages > Your Worker > Triggers
- Add route:
yourdomain.com/*
This worker detects 40+ AI and search bots:
- OpenAI: GPTBot, ChatGPT-User, OAI-SearchBot, SearchGPT
- Anthropic: ClaudeBot, Claude-Web
- Google: Google-Extended, Googlebot
- Perplexity: PerplexityBot
- Microsoft: Bingbot, Copilot
- Meta: FacebookBot, Meta AI
- Apple: Applebot, Applebot-Extended
- xAI: GrokBot
- And 25+ more...
Free tier users display a small badge:
┌─────────────────────────────────────┐
│ 🤖 Bot Traffic by AttractOS │
└─────────────────────────────────────┘
- Fixed position (bottom-right)
- Dark theme
- Cannot be removed via CSS (inline styles)
- Upgrade to Pro to remove
Request → Worker → Detect Bot? → Track (async) → Origin Response
↓
[Badge injection for free tier]
- Worker intercepts all requests
- Checks User-Agent against 40+ bot patterns
- If bot detected, sends tracking event to AttractOS (non-blocking)
- Fetches response from your origin
- For HTML responses on free tier, injects badge before
</body>
- Bot detection: ~0.1ms (string matching)
- Tracking: Non-blocking via
ctx.waitUntil() - Badge injection: Streaming via HTMLRewriter (no buffering)
Total added latency: <1ms
- Dashboard: attractos.com
- Documentation: attractos.com/docs
MIT