Skip to main content

Intro

GPTrends’ Agent Analytics feature allows you to track and analyze how AI agents, bots & crawlers from leading platforms (e.g. OpenAI, Google, Perplexity, and Anthropic) visit and interact with your website.
  • AI bots & agents regularly visit websites to collect, update, and verify information not only for the training of LLMs, but also to power real-time AI search and live answers.
  • This crawling behavior determines which content is available and ingested into AI chat assistants and how your brand and products are represented in AI-generated responses.
  • Importantly, AI bots behave differently than the Google web crawler. Most do not run JavaScript or maintain cookies or session state. If your site is JS heavy or not server-side rendered then there’s a risk that your content is not being ingested correctly.
The overall goal of Agent Analytics is toensure that your most important content & messaging is being discovered and understood by AI platforms.

What’s included in Agent Analytics?

The current version allows you to:
  1. Identify which types of AI agents, bots & crawlers are accessing your site and how often they visit
  2. See which specific pages & topics are being crawled or overlooked
  3. Detect patterns, trends, or technical issues that could impact your AI visibility
  4. Understand how LLMs and AI chatbot apps are building knowledge about your brand, products and services from your website
Bot Analytics Beta UI

Implementation

Because most AI bots bypass JavaScript execution, they don’t show up in tools like Google Analytics and must be tracked from the server side. We currently offer 4 types of integrations:
  1. Server Log Drain (recommended). No code required direct integration with your server logs from Vercel (Netlify, GCP and AWS coming soon).
  2. Next.js SDK. Lightweight, easy to install Next.js JavaScript package.
  3. HTTP API Endpoint. Send event data manually from any backend via an HTTP POST request.
  4. Wordpress plugin. Integrate directly with your Wordpress site, no code required.

Installation Steps

Please find platform specific steps below:
1

Add new 'Custom HTTP endpoint' drain

  • In Vercel navigate to Project Settings and select Drains.
  • Add a new Custom HTTP endpoint drain.
add_drain.png
2

Select "Logs" as data to drain

select_logs.png
3

Configure the drain

  • Drain Name: GPTrends Bot Analytics
  • Projects: Your website project
  • Sources: Select all besides builds
  • Environment: Production
  • Sampling Rate: 100%
4

Set the destination

Add the following POST endpoint URL with your GPTrends API Key appended after ?websiteKey=
https://api.gptrends.io/v1/intake/vercel-log-drain?websiteKey=[YOUR_GPTRENDS_KEY_HERE]
You can find your GPTrends API Key in the Bot Analytics section of the platform, either in the set up flow or under “Manage Tracking”
5

Select 'Create Drain' to save and finish

Need help? Feel free to grab some time with us here and we’ll be happy to walk you through the set up process
1

Step 1

Install the GPTrends tracking package:
npm install @gptrends/track
2

Step 2

Update your middleware.ts file:
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { GPTrendsTrackerNextJS } from "@gptrends/track/nextjs";

const gptrendsTrack = GPTrendsTrackerNextJS({
  websiteKey: "gptrends_secret_...", // Replace with your website key
});

export async function middleware(request: NextRequest) {
  gptrendsTrack(request);
  return NextResponse.next();
}

export const config = {
  matcher: [
    "/robots.txt",
    "/sitemap.xml",
    "/((?!api|_next/static|_next/image|favicon.ico).*)",
  ],
};
Need help? Feel free to grab some time with us here and we’ll be happy to walk you through the set up process
Track bot visits from any backend with a simple GET request:
GET <https://hffpucuigqemqhzokpvw.supabase.co/functions/v1/track-drain>
Required Parameters:
  • url: Full URL accessed
  • userAgent: Bot’s User-Agent header
  • ref: Referrer header (empty if none)
  • ip: Visitor IP
  • websiteKey: Your GPTrends key
Example:
curl "<https://hffpucuigqemqhzokpvw.supabase.co/functions/v1/track-drain?url=https://yourwebsite.com/&userAgent=Mozilla/5.0%20(compatible;%20ChatGPT-User/1.0)&ref=&ip=1.2.3.4&websiteKey=gptrends_secret_your_key_here>"
Notes:
  • Only track key pages (blogs, landing pages, robots.txt, sitemap.xml)
  • Skip static assets
  • Use fire-and-forget requests for zero impact on site speed
  • URL-encode all parameters
Need help? Feel free to grab some time with us here and we’ll be happy to walk you through the set up process
See the Agent Analytics Wordpress plugin page for more info.

Prerequisites

Before starting, make sure you have:
  • Administrator access to your WordPress site
  • The possibility to install plugins on your WordPress installation
1

Open the Plugins panel

Open your WordPress website’s admin panel: https://<yourwebsite>.com/wp-adminIn the left sidebar, navigate to: PluginsWp Add Plugin Pn
2

Search for GPTrends

Search for GPTrends in the Plugins search barSearch for GPTrends plugin
3

Install the Plugin

Click Install Now to install the plugin.
4

Activate the Plugin

Back in the Plugins section, you should see GPTrends listed.Click Activate under the plugin’s title.Wp Activate Plugin Pn
5

Configure the Plugin

Finally, in the left sidebar, click Settings then GPTrends to open the plugin’s settings page.
  1. Leave Enable Tracking checked: this allows AI agents, bots and crawlers to be tracked. Unchecking this will pause tracking.
  2. Paste your website’s GPTrends API key. You can get this from the GPTrends dashboard, under Agent Analytics > Manage Configuration
  3. Leave API Endpoing empty (only needed for testing). Wp Configure Plugin Pn Finally, click Save Changes to apply.

Security, Privacy & Performance

  • No Personal Identifying Information (PII) from users is stored or logged
  • The log drain approach occurs outside of the run path and has no impact on your website performance
  • The Next.js package and Wordpress plugin run in a fire-and-forget mode inside middleware; requests are not awaited, so it has no impact on site performance or page load times
  • All errors are safely caught, logged, and discarded — ensuring your site runs exactly as before, with zero interference to end users
Need help? Feel free to grab some time with us here and we’ll be happy to walk you through the set up process