Skip to content

Install

The snippet runs on the request path. AI fetchers do not execute JavaScript, so a client beacon will miss them. Create a site in Snippet to get a token. GET only. We never log the body.

HTTP

Any origin that can POST JSON. WordPress, PHP, and custom servers use this contract.

curl -X POST https://theyfetch.com/api/ingest \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "timestamp": "2026-09-02T10:00:00Z",
    "method": "GET",
    "url": "https://example.com/blog/post",
    "ip": "203.0.113.5",
    "geo": { "country": "GB" },
    "referer": "https://chatgpt.com/",
    "userAgent": "Mozilla/5.0 ... ChatGPT-User/1.0 ...",
    "status": 200
  }'

Next.js

Middleware or proxy on the request. Not a client component.

import { Tracker } from "@theyfetch/next";
import { type NextFetchEvent, type NextRequest, NextResponse } from "next/server";

const tracker = new Tracker({ token: "YOUR_TOKEN" });

export function proxy(request: NextRequest, event: NextFetchEvent) {
  tracker.track(request, event);
  return NextResponse.next();
}

export const config = {
  matcher: ["/((?!_next/static|_next/image).*)"],
};

// Older Next.js: export function middleware(...) with the same body.
// App Router: wrap tracker.track(request) in after(() => { ... }).
// AI crawlers do not run JavaScript, so this must stay on the request path.

Cloudflare Worker

Wrap the existing worker, or add the snippet in front of a static site.

import { theyfetch } from "@theyfetch/worker";

export default theyfetch({ token: "YOUR_TOKEN" });

Astro, Nuxt, TanStack Start and WordPress packages live in the same repo. Do not publish them to npm until we say so. Link them locally.