A Cloudflare Worker sits in front of your site and reports every agent request to Rankly, then passes the request through untouched. It works on the free Cloudflare plan and takes about three minutes.
Prerequisites. Your domain is on Cloudflare (active zone), and you have verified it in Rankly. Your ingest token is in Settings and is already baked into the script Rankly generates for you.

Setup

1

Create a Worker

In the Cloudflare dashboard, go to Workers & Pages -> Create -> Create Worker. Give it a name like rankly-agent-analytics.
2

Paste the Worker script

Replace the default code with the script below. Rankly generates this for you with your ingest token already filled in; the version here shows the shape.
rankly-worker.js
// Rankly Agent Analytics: Cloudflare Worker
const RANKLY_INGEST = 'https://ingest.tryrankly.com/ingest/cloudflare-worker';
const RANKLY_TENANT_TOKEN = 'tnt_your_token';

const BOT_UA_RE = /\b(GPTBot|ChatGPT-User|OAI-SearchBot|ClaudeBot|Claude-User|PerplexityBot|Perplexity-User|Google-Extended|Bytespider|Amazonbot|Applebot-Extended|DuckAssistBot|GrokBot|CCBot|Meta-ExternalAgent|MistralAI-User|cohere-ai|Amazon-Rufus|Shop-Agent)\b/i;
const LLM_REFERRER_RE = /(^|\.)(chatgpt\.com|openai\.com|perplexity\.ai|claude\.ai|gemini\.google\.com|copilot\.microsoft\.com|you\.com|grok\.com|mistral\.ai)$/i;

export default {
  async fetch(req, env, ctx) {
    const response = await fetch(req);   // pass through to your origin
    ctx.waitUntil(report(req, response)); // report in the background
    return response;
  },
};

async function report(req, res) {
  const ua = req.headers.get('user-agent') || '';
  const sigAgent = req.headers.get('signature-agent');
  const u = new URL(req.url);
  const isFavicon = /^\/favicon[.-]|^\/apple-touch-icon/i.test(u.pathname);
  let llmReferred = false;
  try { const rh = req.headers.get('referer'); if (rh) llmReferred = LLM_REFERRER_RE.test(new URL(rh).hostname); } catch (_) {}
  if (!BOT_UA_RE.test(ua) && !sigAgent && !isFavicon && !llmReferred) return;

  const payload = {
    ts: Date.now(), ua, method: req.method,
    host: u.hostname, path: u.pathname,
    country: req.cf?.country || null,
    ip: req.headers.get('cf-connecting-ip'),
    referer: req.headers.get('referer') || null,
    status: res.status,
    signatureAgent: sigAgent,
    signatureInput: req.headers.get('signature-input') || null,
    signature: req.headers.get('signature') || null,
  };
  try {
    await fetch(RANKLY_INGEST + '?tenant=' + RANKLY_TENANT_TOKEN, {
      method: 'POST',
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify(payload),
      keepalive: true,
    });
  } catch (_) { /* never block the request */ }
}
Click Deploy.
3

Bind the Worker to your routes

Open your domain’s zone, go to Workers Routes, and add routes so the Worker runs on your whole site:
yourdomain.com/*
www.yourdomain.com/*
4

Send a test request

curl -A "GPTBot/1.0" https://www.yourdomain.com/
Your first event appears in the dashboard within a minute.
The Worker captures the real client IP (cf-connecting-ip) and Web Bot Auth signatures at the edge, so IP verification and signed-request checks work out of the box.

Notes

No. The Worker calls fetch(req) to your origin and reports the event in the background with waitUntil. The visitor’s response is never delayed.
The free Workers plan covers 100,000 requests per day. Above that, add the Workers Paid plan ($5/mo) in your Cloudflare account.
Use the Shopify guide, which sets up this same Worker on your own domain and points it at your store for you.