ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Build an AEO Pixel to Detect LLM-Agent Hits
Tutorial

How to Build an AEO Pixel to Detect LLM-Agent Hits

Drop a lightweight AEO pixel on your site to detect when ChatGPT, Claude, and Perplexity agents fetch your pages. Score AEO performance in real time.

Get Free API KeyAPI Docs

An AEO pixel is the analytics equivalent of Google Analytics for agent traffic. It detects when LLM agents (ChatGPT-User, ClaudeBot, PerplexityBot, OAI-SearchBot) fetch your page during a user's AI session. This tutorial wires a minimal AEO pixel that reports to your backend and classifies unknown UAs via Scavio reverse lookup.

Prerequisites

  • Node 20+ backend or edge runtime
  • A Scavio API key
  • A simple logging destination (Supabase, SQLite, PostHog)

Walkthrough

Step 1: Add the pixel middleware

Run a middleware that inspects every HTML page fetch.

JavaScript
export async function aeoPixel(req, res, next) {
  const ua = req.headers['user-agent'] || '';
  const type = classify(ua);
  if (type !== 'human') await log({ ua, path: req.path, type, ts: Date.now() });
  next();
}

Step 2: Classify known agents

Hard-coded list of documented agent UAs.

JavaScript
const KNOWN = [/ChatGPT-User/, /GPTBot/, /ClaudeBot/, /PerplexityBot/, /OAI-SearchBot/];
function classifyKnown(ua) {
  return KNOWN.find(r => r.test(ua))?.source || null;
}

Step 3: Reverse lookup unknown UAs with Scavio

Scavio search confirms if an unknown UA is a documented bot.

JavaScript
async function reverseLookup(ua) {
  const r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: `\"${ua}\" bot user agent` })
  });
  const d = await r.json();
  return d.organic_results?.some(o => /bot|crawler/i.test(o.snippet)) ? 'suspected_agent' : 'human';
}

Step 4: Log to Supabase

One row per agent hit.

JavaScript
import { createClient } from '@supabase/supabase-js';
const supa = createClient(URL, KEY);
export const log = (row) => supa.from('aeo_pixel').insert(row);

Step 5: Build a dashboard

Daily hits per agent, trend over time.

-- Supabase SQL
SELECT DATE(ts), type, COUNT(*) FROM aeo_pixel GROUP BY 1, 2 ORDER BY 1;

Python Example

Python
import os, requests, re

API_KEY = os.environ['SCAVIO_API_KEY']
KNOWN = [r'ChatGPT-User', r'GPTBot', r'ClaudeBot', r'PerplexityBot']

def classify(ua):
    for p in KNOWN:
        if re.search(p, ua): return p
    r = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY}, json={'query': f'"{ua}" bot'})
    return 'suspected_agent' if r.json().get('organic_results') else 'human'

print(classify('ClaudeBot/2.0'))

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;
const KNOWN = [/ChatGPT-User/, /GPTBot/, /ClaudeBot/, /PerplexityBot/];
export async function classify(ua) {
  const m = KNOWN.find(r => r.test(ua));
  if (m) return m.source;
  const r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: `"${ua}" bot` })
  });
  const d = await r.json();
  return d.organic_results?.length ? 'suspected_agent' : 'human';
}

Expected Output

JSON
Dashboard showing daily AEO pixel hits split by agent. B2B sites typically see 100-1000 agent hits per 1000 human sessions by Q2 2026.

Related Tutorials

  • How to Measure Agentic Traffic in Real Time
  • How to Track ChatGPT Citations for Your Brand
  • How to Build an AEO Dashboard

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Node 20+ backend or edge runtime. A Scavio API key. A simple logging destination (Supabase, SQLite, PostHog). A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Solution

Detect AI Agent Visits in Real Time

Read more
Best Of

Best AEO Tracking Tools for SaaS Founders in 2026

Read more
Best Of

Best Tools for Building Agents Without Frameworks (2026)

Read more
Use Case

Optimize AI Agent Data Access Scope

Read more
Workflow

Agentic Traffic Pixel Real-Time Dashboard

Read more
Workflow

Agent Search Cost and Budget Tracking Workflow

Read more

Start Building

Drop a lightweight AEO pixel on your site to detect when ChatGPT, Claude, and Perplexity agents fetch your pages. Score AEO performance in real time.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy