Skip to content

Docs Analytics

Install Analytics

The visitor code counts people on every site. Bot tracking counts AI assistants and search bots, and needs the place that answers each request to report it. The app picks the way that fits your site. This page shows each way.

Start in the app

  1. Step 1

    Open Analytics

    In BlazeHive

    In BlazeHive, pick your website and open Analytics.

    Open BlazeHive
  2. Step 2

    Follow the one block you see

    We look at your site and show the one way that fits it. Other ways are under Other ways.

  3. Step 3

    Wait for the two checks

    People are being counted shows after the first visit. Bot tracking works shows after our test visit.

Someone else runs your site? Click Send to my developer. The email has the steps and a link back. It holds no secret. Your visitor code is also in Analytics settings, Install, Visitor code.

WordPress

The BlazeHive Connect plugin, version 2.8.0 or newer, adds Analytics by itself. Connect the plugin, then open Analytics in BlazeHive. You see We added Analytics to your site. You do not need to do anything.

  • The plugin adds the visitor code to every page. It skips wp-admin, and it does not count people logged in as editors.
  • It reports bot visits after each page is sent. It never slows a page.
  • In WordPress, the BlazeHive screen has two switches: Count visitors and Send AI and search bot visits. Turning one off there always wins.
  • In BlazeHive, you can turn Analytics off on WordPress and back on.
  • Uninstalling the plugin removes everything it stored.

Page caches

A page cache answers some visits before WordPress runs, so the plugin never sees them. The plugin makes AI bots skip the cache where the cache allows it. Search engines stay on the cache, so their counts are partial on cached sites.

CacheWhat happens
WP Rocket, LiteSpeed Cache, WP Super Cache, W3 Total Cache, WP-OptimizeAI bots skip the cache on their own. With W3 Total Cache in "Disk: Enhanced" mode, open its settings and click Save once.
WP Fastest CacheAdd the AI tools under its Exclude settings yourself. The plugin cannot change it.
SiteGround Optimizer, Cache Enabler, Breeze, HummingbirdThe plugin cannot make bots skip these caches. Coverage is Partial.
Host caches: Kinsta, WP Engine, Flywheel, Pantheon, Pressable, WordPress.com, GoDaddy, VarnishThe cache runs outside WordPress. Coverage is Partial.
Cloudflare APOThe cache runs at Cloudflare. Connect Cloudflare to see every bot.
If your site runs on Cloudflare, Connect Cloudflare sees every bot, even on saved pages. The plugin then stops reporting bots, so nothing is counted twice.

Cloudflare

For a site that runs through your own Cloudflare account. The app shows this only when it sees your site on Cloudflare.

  1. Click Connect Cloudflare.
  2. Pick the Cloudflare account that has your site, and click Authorize. Cloudflare asks for four permissions: read your zones, edit Workers scripts, edit Workers routes, and stay connected.
  3. Back in BlazeHive, wait for Cloudflare is connected. The app then tests bot tracking.

What we add to your Cloudflare

One small Worker, named blazehive-analytics- followed by a code for your project, and one route <your host>/* for each address of your site (your domain and www., or just your subdomain).

  • It passes every request to your site unchanged and returns your site's answer. It never blocks, caches, rewrites or changes a status.
  • When a bot asks for a page, it reports the visit in the background, after the answer is on its way.
  • For people, it adds the visitor code to your HTML pages, unless the page already has it. You can turn this off.
  • It reports robots.txt, llms.txt, sitemaps, redirects and 404s. It skips images, styles, scripts, fonts and other files.

Each request counts toward your Cloudflare Workers allowance. On the free plan that is 100,000 requests a day. Past that, your site keeps working and only bot tracking pauses until the next day.

Remove it

In Analytics settings, Bots, click Disconnect Cloudflare. We remove our routes and the Worker, and give the access back. If you took our access away in Cloudflare first, we cannot remove them. Then, in Cloudflare, delete the Worker whose name starts with blazehive-analytics-, and remove its routes from your site's Workers Routes.

You already run your own Worker

Cloudflare runs one Worker per request. If your own Worker already covers your whole site, we do not add ours, because it would take requests away from yours. The app shows Your site already runs its own code on Cloudflare and these lines to add to your Worker instead. Add a Worker secret named BLAZEHIVE_TOKEN. Its value, your bot token, is in the app for editors.

Add to your Worker
// BlazeHive Analytics: report AI and search bot visits.
// 1. Add a secret to this Worker: BLAZEHIVE_TOKEN (the value is below this code).
// 2. Paste these two lines at the top of the file, outside your handler.
const BLAZEHIVE_BOT = /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i;
const BLAZEHIVE_ASSET = /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i;

// 3. In your fetch(request, env, ctx) handler, right after you have the response and before you return it.
//    If your handler uses other names for request, response, env or ctx, use yours.
try {
  const ua = request.headers.get("user-agent") || "";
  if ((request.method === "GET" || request.method === "HEAD") && BLAZEHIVE_BOT.test(ua) && !BLAZEHIVE_ASSET.test(new URL(request.url).pathname) && env.BLAZEHIVE_TOKEN) {
    ctx.waitUntil(fetch("https://data.blazehive.io/api/ai-crawls/ingest", {
      method: "POST",
      headers: { "content-type": "application/json", "x-blazehive-token": env.BLAZEHIVE_TOKEN },
      body: JSON.stringify({ url: request.url, userAgent: ua.slice(0, 500), ip: request.headers.get("cf-connecting-ip") || undefined, status: response.status, timestamp: new Date().toISOString(), source: "cloudflare" }),
    }).catch(() => {}));
  }
} catch (e) {
  // Reporting must never break your site.
}

If your Worker covers only some paths (for example /api/*), we add ours and list the paths we cannot see.

No login to Cloudflare

Click I can't log in to Cloudflare. The app writes an email to the person who manages it. They open the link below, which fills in the three permissions (Zone Read, Workers Scripts Write, Workers Routes Write), create a token, and send it to you. You paste it in the app. Use this way too if your Cloudflare account blocks apps from other companies.

Open the Cloudflare token page with the three permissions

Sites built with code

For Next.js, Vercel, Netlify, Replit, Node, Laravel, PHP, Python, Ruby and Astro sites, and for Lovable, Bolt and Base44. The app gives you one message for your coding agent. It holds your site's own values, so copy it from the app.

  1. Step 1

    Copy the message.

  2. Step 2

    Paste it into your coding agent, like Cursor, Claude Code, Lovable, Replit or v0.

  3. Step 3

    Publish your site when the agent is done.

  4. Step 4

    Paste the last line your agent wrote below.

Then click I added it. The app tests your live site. The last line your agent prints is one of these:

Your agent's last line
BlazeHive Analytics: visitor code added, bot reporting added
BlazeHive Analytics: visitor code added, bot reporting not possible on this site (no server)

The message holds your private bot token, so only editors of the project can copy it.

Bot code by stack

This is the code the message asks your agent to add, for developers who want to read it first or add it by hand. Use your own visitor code and bot token from the app.

1. The visitor code

Once per page, in the <head>, on every public page.

Visitor code (yours has your site id and domain)
<script defer data-site-id="YOUR_SITE_ID" data-domain="example.com" src="https://data.blazehive.io/js/script.js"></script>

2. The bot report

One request per bot visit, sent by your server after it answered. Keep the bot token in an environment variable named BLAZEHIVE_TOKEN. Never put it in the page.

The request
POST https://data.blazehive.io/api/ai-crawls/ingest
Content-Type: application/json
x-blazehive-token: <the bot key, from the BLAZEHIVE_TOKEN environment variable>

{ "url": "https://example.com/pricing?ref=chat", "userAgent": "<the request's User-Agent>", "ip": "<the visitor IP, see 2.4>",
  "status": 200, "timestamp": "2026-11-25T10:00:00.000Z", "source": "middleware" }
FieldRule
urlThe full requested URL with its query string (or just the path).
userAgentThe request's User-Agent, cut to 500 characters.
ipOnly from the trusted place in 2.4. Leave the field out when you have none.
statusThe status code you answered (200, 301, 404 ...), as an integer. Leave the field out when your code runs before the status is known. Never send null.
timestampWhen the request came in, ISO 8601.
sourceAlways "middleware".

3. Which requests to report

Report a request when all of these are true. The pattern is loose on purpose: we decide what the bot really is.

  1. The method is GET or HEAD.
  2. The User-Agent matches this pattern, case-insensitive:
    /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i
  3. The path does not match this pattern:
    /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i

4. The visitor IP (section 2.4 in the code comments)

We check a bot's address against the addresses its company publishes. So only send an IP you can trust.

Where your site runsTake the IP from
Vercelthe x-real-ip header
Netlifythe x-nf-client-connection-ip header
Fly.iothe fly-client-ip header
Behind Cloudflare, and the server only accepts traffic from Cloudflarethe cf-connecting-ip header
Your own server with no proxy, load balancer or CDN in frontthe connection's own address (the socket)
Anything else (Render, Railway, Heroku, Replit, an unknown proxy), or you are not surenothing: leave ip out

Never take the IP from x-forwarded-for yourself.

Next.js

Next.js runs one middleware file for the whole app. From Next.js 16 it is proxy.ts exporting proxy. Before 16 it is middleware.ts exporting middleware. If the file exists, add the BlazeHive part inside it and keep what it does. A middleware runs before the page, so it sends no status.

proxy.ts (Next.js 16+) or middleware.ts with "export function middleware" (Next.js 15 and older)
// proxy.ts (Next.js 16+)  or  middleware.ts with "export function middleware" (Next.js 15 and older)
import { NextResponse, type NextFetchEvent, type NextRequest } from "next/server";

const BLAZEHIVE_BOT = /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i;
const BLAZEHIVE_ASSET = /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i;
const BLAZEHIVE_INGEST = "https://data.blazehive.io/api/ai-crawls/ingest";
// The trusted IP header for this host (section 2.4), or null to send no IP. On Vercel: "x-real-ip".
const BLAZEHIVE_IP_HEADER: string | null = null;

function reportBot(request: NextRequest, event: NextFetchEvent): void {
  try {
    const token = process.env.BLAZEHIVE_TOKEN;
    const ua = request.headers.get("user-agent") || "";
    if (!token || (request.method !== "GET" && request.method !== "HEAD")) return;
    if (!BLAZEHIVE_BOT.test(ua) || BLAZEHIVE_ASSET.test(request.nextUrl.pathname)) return;
    const body: Record<string, unknown> = { url: request.url, userAgent: ua.slice(0, 500), timestamp: new Date().toISOString(), source: "middleware" };
    const ip = BLAZEHIVE_IP_HEADER ? (request.headers.get(BLAZEHIVE_IP_HEADER) || "").split(",")[0].trim() : "";
    if (ip) body.ip = ip;
    event.waitUntil(
      fetch(BLAZEHIVE_INGEST, {
        method: "POST",
        headers: { "content-type": "application/json", "x-blazehive-token": token },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(3000),
      }).then(() => undefined, () => undefined),
    );
  } catch {
    // Reporting must never break the site.
  }
}

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

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

Node.js (Express, or any Node server with req/res)

Add this file and use it as the first middleware, before static files and routes. It reports when the response is done, with the real status.

blazehive-bots.js (ES modules: replace module.exports with export default)
// blazehive-bots.js  (ES modules: replace module.exports with export default)
const BLAZEHIVE_BOT = /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i;
const BLAZEHIVE_ASSET = /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i;
const BLAZEHIVE_INGEST = "https://data.blazehive.io/api/ai-crawls/ingest";
// Where the visitor IP comes from (section 2.4): a header name such as "x-real-ip", "socket" for a server with
// no proxy in front, or null to send no IP.
const BLAZEHIVE_IP_FROM = null;

function clientIp(req) {
  if (BLAZEHIVE_IP_FROM === "socket") return req.socket?.remoteAddress || "";
  if (BLAZEHIVE_IP_FROM) return String(req.headers[BLAZEHIVE_IP_FROM] || "").split(",")[0].trim();
  return "";
}

function blazehiveBots(req, res, next) {
  try {
    const token = process.env.BLAZEHIVE_TOKEN;
    const ua = String(req.headers["user-agent"] || "");
    const path = String(req.originalUrl || req.url || "/").split("?")[0];
    if (token && (req.method === "GET" || req.method === "HEAD") && BLAZEHIVE_BOT.test(ua) && !BLAZEHIVE_ASSET.test(path)) {
      const at = new Date().toISOString();
      res.once("finish", () => {
        try {
          const body = { url: "https://" + (req.headers.host || "example.com") + (req.originalUrl || req.url), userAgent: ua.slice(0, 500), status: res.statusCode, timestamp: at, source: "middleware" };
          const ip = clientIp(req);
          if (ip) body.ip = ip;
          fetch(BLAZEHIVE_INGEST, {
            method: "POST",
            headers: { "content-type": "application/json", "x-blazehive-token": token },
            body: JSON.stringify(body),
            signal: AbortSignal.timeout(3000),
          }).catch(() => {});
        } catch {
          // never break the site
        }
      });
    }
  } catch {
    // never break the site
  }
  next();
}

module.exports = blazehiveBots;
where the app is created
// where the app is created
const blazehiveBots = require("./blazehive-bots");
app.use(blazehiveBots); // first, before express.static and the routes

fetch is built into Node 18 and newer. On an older Node, use https.request with a 3 second timeout instead. On a serverless host (Vercel functions, Netlify functions) a request is frozen once the response is sent, so use the host's waitUntil (Vercel: import { waitUntil } from "@vercel/functions") around the fetch.

Astro (server output)

For Astro with server output. Add it as src/middleware.ts, or add it to your onRequest. Keep the waitUntil line for your adapter and delete the others. Pages built ahead of time never run middleware, so bot visits to them are not reported.

src/middleware.ts
// src/middleware.ts
import { defineMiddleware } from "astro:middleware";

const BLAZEHIVE_BOT = /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i;
const BLAZEHIVE_ASSET = /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i;
const BLAZEHIVE_INGEST = "https://data.blazehive.io/api/ai-crawls/ingest";
// The trusted IP header for this host (section 2.4), or null to send no IP.
const BLAZEHIVE_IP_HEADER: string | null = null;

export const onRequest = defineMiddleware(async (context, next) => {
  const response = await next();
  try {
    const token = import.meta.env.BLAZEHIVE_TOKEN ?? process.env.BLAZEHIVE_TOKEN;
    const request = context.request;
    const ua = request.headers.get("user-agent") || "";
    if (token && (request.method === "GET" || request.method === "HEAD") && BLAZEHIVE_BOT.test(ua) && !BLAZEHIVE_ASSET.test(context.url.pathname)) {
      const body: Record<string, unknown> = { url: context.url.href, userAgent: ua.slice(0, 500), status: response.status, timestamp: new Date().toISOString(), source: "middleware" };
      const ip = BLAZEHIVE_IP_HEADER ? (request.headers.get(BLAZEHIVE_IP_HEADER) || "").split(",")[0].trim() : "";
      if (ip) body.ip = ip;
      const sent = fetch(BLAZEHIVE_INGEST, { method: "POST", headers: { "content-type": "application/json", "x-blazehive-token": token }, body: JSON.stringify(body), signal: AbortSignal.timeout(3000) }).catch(() => {});
      // Keep the report alive after the response on serverless adapters:
      // @astrojs/cloudflare: context.locals.runtime.ctx.waitUntil(sent)
      // @astrojs/vercel:     import { waitUntil } from "@vercel/functions"; waitUntil(sent)
      // @astrojs/netlify:    context.locals.netlify.context.waitUntil(sent)
      // @astrojs/node:       nothing to add
      void sent;
    }
  } catch {
    // Reporting must never break the site.
  }
  return response;
});

Laravel

A terminable middleware: terminate() runs after the response was sent, so the visitor never waits.

app/Http/Middleware/BlazeHiveBots.php
<?php
// app/Http/Middleware/BlazeHiveBots.php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Symfony\Component\HttpFoundation\Response;

class BlazeHiveBots
{
    private const BOT = '/bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i';
    private const ASSET = '/\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i';
    private const INGEST = 'https://data.blazehive.io/api/ai-crawls/ingest';
    // Where the visitor IP comes from (section 2.4): a header name such as 'x-real-ip', 'socket' for a server with
    // no proxy in front, or null to send no IP.
    private const IP_FROM = null;

    public function handle(Request $request, Closure $next): Response
    {
        return $next($request);
    }

    public function terminate(Request $request, Response $response): void
    {
        try {
            $token = config('services.blazehive.token');
            $ua = (string) $request->userAgent();
            if (! $token || ! in_array($request->method(), ['GET', 'HEAD'], true)) return;
            if (! preg_match(self::BOT, $ua) || preg_match(self::ASSET, '/'.ltrim($request->path(), '/'))) return;
            $body = [
                'url' => $request->fullUrl(),
                'userAgent' => mb_substr($ua, 0, 500),
                'status' => $response->getStatusCode(),
                'timestamp' => now()->toIso8601String(),
                'source' => 'middleware',
            ];
            $ip = match (self::IP_FROM) {
                null => '',
                'socket' => (string) $request->server('REMOTE_ADDR'),
                default => trim(explode(',', (string) $request->header(self::IP_FROM))[0]),
            };
            if ($ip !== '') $body['ip'] = $ip;
            Http::timeout(3)->withHeaders(['x-blazehive-token' => $token])->asJson()->post(self::INGEST, $body);
        } catch (\Throwable $e) {
            // Reporting must never break the site.
        }
    }
}
  • Add 'blazehive' => ['token' => env('BLAZEHIVE_TOKEN')] to config/services.php and BLAZEHIVE_TOKEN=... to the production .env (never committed).
  • Register it for every request. Laravel 11 and newer, in bootstrap/app.php: ->withMiddleware(function (Middleware $middleware) { $middleware->append(\App\Http\Middleware\BlazeHiveBots::class); }). Laravel 10 and older: add it to $middleware in app/Http/Kernel.php.
  • Run php artisan config:cache again after deploying if the app uses it.

Plain PHP

Include this file at the very top of your front controller. It decides at once, then reports after the page was sent.

blazehive-bots.php
<?php
// blazehive-bots.php

(function (): void {
    try {
        $token = getenv('BLAZEHIVE_TOKEN') ?: ($_SERVER['BLAZEHIVE_TOKEN'] ?? '');
        $method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
        $ua = (string) ($_SERVER['HTTP_USER_AGENT'] ?? '');
        $uri = (string) ($_SERVER['REQUEST_URI'] ?? '/');
        $path = (string) parse_url($uri, PHP_URL_PATH);
        if ($token === '' || ($method !== 'GET' && $method !== 'HEAD')) return;
        if (!preg_match('/bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i', $ua) || preg_match('/\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i', $path)) return;
        // Where the visitor IP comes from (section 2.4): a $_SERVER key such as 'HTTP_X_REAL_IP', 'REMOTE_ADDR' for a
        // server with no proxy in front, or '' to send no IP.
        $ipFrom = '';
        $at = gmdate('c');
        register_shutdown_function(function () use ($token, $ua, $uri, $ipFrom, $at): void {
            try {
                if (function_exists('fastcgi_finish_request')) fastcgi_finish_request(); // the visitor stops waiting here
                $host = (string) ($_SERVER['HTTP_HOST'] ?? 'example.com');
                $body = ['url' => 'https://' . $host . $uri, 'userAgent' => substr($ua, 0, 500), 'timestamp' => $at, 'source' => 'middleware'];
                $status = http_response_code();
                if (is_int($status)) $body['status'] = $status;
                $ip = $ipFrom !== '' ? trim(explode(',', (string) ($_SERVER[$ipFrom] ?? ''))[0]) : '';
                if ($ip !== '') $body['ip'] = $ip;
                $ch = curl_init('https://data.blazehive.io/api/ai-crawls/ingest');
                curl_setopt_array($ch, [
                    CURLOPT_POST => true,
                    CURLOPT_POSTFIELDS => json_encode($body),
                    CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'x-blazehive-token: ' . $token],
                    CURLOPT_RETURNTRANSFER => true,
                    CURLOPT_CONNECTTIMEOUT => 2,
                    CURLOPT_TIMEOUT => 3,
                ]);
                curl_exec($ch);
                curl_close($ch);
            } catch (\Throwable $e) {
                // Reporting must never break the site.
            }
        });
    } catch (\Throwable $e) {
        // Reporting must never break the site.
    }
})();

Then require __DIR__ . '/blazehive-bots.php'; as the first line of index.php (or the shared bootstrap file). If the host has no environment variables, keep the key in a PHP config file outside the web root and read it there.

Python (Django, Flask, FastAPI)

Call report(...) after each response. It sends from a background thread with a 3 second timeout.

blazehive_bots.py
# blazehive_bots.py
import json, os, re, threading, urllib.request
from datetime import datetime, timezone

BOT = re.compile(r"bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify", re.I)
ASSET = re.compile(r"\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$", re.I)
INGEST = "https://data.blazehive.io/api/ai-crawls/ingest"

def _send(body, token):
    try:
        req = urllib.request.Request(INGEST, data=json.dumps(body).encode(), method="POST",
                                     headers={"Content-Type": "application/json", "x-blazehive-token": token})
        urllib.request.urlopen(req, timeout=3).close()
    except Exception:
        pass  # never break the site

def report(method, url, path, user_agent, status, ip=None):
    """Call after the response is ready. ip: only from section 2.4, else None."""
    try:
        token = os.environ.get("BLAZEHIVE_TOKEN")
        if not token or method not in ("GET", "HEAD") or not BOT.search(user_agent or "") or ASSET.search(path or ""):
            return
        body = {"url": url, "userAgent": (user_agent or "")[:500], "status": int(status),
                "timestamp": datetime.now(timezone.utc).isoformat(), "source": "middleware"}
        if ip:
            body["ip"] = ip
        threading.Thread(target=_send, args=(body, token), daemon=True).start()
    except Exception:
        pass
  • Django: a middleware class whose __call__ gets response = self.get_response(request), then calls report(request.method, request.build_absolute_uri(), request.path, request.META.get("HTTP_USER_AGENT", ""), response.status_code) and returns the response. Add it to MIDDLEWARE.
  • Flask: @app.after_request calling report(request.method, request.url, request.path, request.headers.get("User-Agent", ""), response.status_code), returning the response.
  • FastAPI / Starlette: an @app.middleware("http") that awaits call_next(request), then calls report(...) with response.status_code.

Ruby (Rails or any Rack app)

Rack middleware. In Rails, add it with config.middleware.insert_before 0, BlazehiveBots.

lib/blazehive_bots.rb (Rails: config.middleware.insert_before 0, BlazehiveBots)
# lib/blazehive_bots.rb  (Rails: config.middleware.insert_before 0, BlazehiveBots)
require "json"
require "net/http"
require "time"

class BlazehiveBots
  BOT = /bot|crawl|spider|slurp|chatgpt|oai-|openai|claude|anthropic|perplexity|google-|googleother|googleagent|gemini|notebooklm|bingpreview|duckassist|mistral|cohere|deepseek|amazon|amzn-|meta-external|facebookexternal|webindexer|diffbot|copilot|grok|hunyuan|-user\b|fetcher|blazehive-verify/i
  ASSET = /\.(?:css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|mp3|wav|ogg|pdf|zip|gz|wasm)$/i
  INGEST = URI("https://data.blazehive.io/api/ai-crawls/ingest")

  def initialize(app)
    @app = app
  end

  def call(env)
    status, headers, body = @app.call(env)
    begin
      token = ENV["BLAZEHIVE_TOKEN"]
      ua = env["HTTP_USER_AGENT"].to_s
      if token && %w[GET HEAD].include?(env["REQUEST_METHOD"]) && ua.match?(BOT) && !env["PATH_INFO"].to_s.match?(ASSET)
        req = Rack::Request.new(env)
        hit = { url: req.url, userAgent: ua[0, 500], status: status.to_i, timestamp: Time.now.utc.iso8601, source: "middleware" }
        Thread.new do
          Net::HTTP.start(INGEST.host, INGEST.port, use_ssl: INGEST.scheme == "https", open_timeout: 2, read_timeout: 3) do |http|
            http.post(INGEST.path, hit.to_json, "Content-Type" => "application/json", "x-blazehive-token" => token)
          end
        rescue StandardError
          nil
        end
      end
    rescue StandardError
      nil # never break the site
    end
    [status, headers, body]
  end
end

Add an ip only from section 2.4.

A site with no server

Lovable, Bolt, Base44 and other sites made only of files have no request to hook. Add the visitor code only. Bots cannot be counted there, unless the site runs through your own Cloudflare.

Site builders

Shopify, Webflow, Wix, Framer, Squarespace, HubSpot and Ghost: paste your visitor code in the site settings. Copy it from the app, in Analytics settings, Install, Visitor code.

Shopify

  1. In Shopify, open Online Store, then Themes.
  2. Next to your theme, click the three dots, then Edit code.
  3. Open theme.liquid. Paste the code just above </head>, then click Save.

Webflow

  1. In Webflow, open Site settings, then Custom code.
  2. Paste the code in the Head code box and save.
  3. Publish your site.

Wix

  1. In your Wix dashboard, open Settings, then Custom Code.
  2. Click Add Custom Code and paste the code. Pick All pages and Head.
  3. Click Apply.

Framer

  1. In Framer, open your site settings and find Custom code.
  2. Paste the code in the box for the end of the head.
  3. Publish your site.

Squarespace

  1. In Squarespace, open Settings and find Code injection.
  2. Paste the code in the Header box.
  3. Click Save.

HubSpot

  1. In HubSpot settings, find the settings for your website pages.
  2. Paste the code in the site header HTML box.
  3. Click Save.

Ghost

  1. In Ghost Admin, open Settings and find Code injection.
  2. Paste the code in the Site header box.
  3. Click Save.

Any other builder

  1. Open your site settings and find custom code.
  2. Paste the code in the box for the head of every page.
  3. Save and publish your site.
This platform does not let anyone see bot visits. You will still see people who come from ChatGPT and other AI tools.

Test it

The app runs the test for you after each install. To test a server by hand, request a page with the test user agent and check that your code sent one report:

Terminal
curl -s -o /dev/null -A "BlazeHive-Verify/1.0 (+https://www.blazehive.io) nonce=agentselftest00001" http://localhost:<port>/

Or send one bot visit from your server with your bot token:

Send one bot visit
curl -X POST https://data.blazehive.io/api/ai-crawls/ingest \
  -H "Authorization: Bearer <your bot token>" \
  -H "Content-Type: application/json" \
  -d '{"url":"/pricing","userAgent":"<User-Agent of the request>","ip":"<IP of the request>","status":200}'

A 200 answer counts what was stored. 401 means the token is wrong. The token is in Analytics settings, Install, For developers. For every field and answer, see the bot report reference.

Docs menu · Install Analytics