Developers

Build on AnalyzeUser

One script tag tracks your site. Attributes and a small JavaScript API add events. A REST API reads your analytics, and the Payment API reports sales from any checkout so revenue lands on the source that brought the buyer. AI agents use the same data over MCP.

Install

Add this to every page, before </head>. Your site id is on the project's setup screen. Step-by-step for your platform: install guides (Next.js, WordPress, Webflow, Framer, Shopify, Google Tag Manager and more).

<script defer src="https://analyzeuser.com/track.js" data-site-id="YOUR_SITE_ID"></script>

Single-page apps are handled: route changes count as pageviews. Nothing is sent from localhost. Optional attributes on the script tag:

data-track-outbound="false"   stop recording clicks to other sites (on by default)
data-track-clicks="true"      record every click on links and buttons (off by default)
data-domains="example.app"    other domains of the same site (see below)

Subdomains and www are one site already: a visitor who moves from example.com to app.example.com stays one person. For a site on more than one domain, list the others under Project settings -> General and in data-domains on the script tag on every domain, and links between them carry the visitor across too.

Custom events

From JavaScript, with up to a handful of properties:

window.analyzeUser.track("signup", { plan: "pro" });

Or with no JavaScript - a click on the element records the event, with its data-au-prop-* values as properties:

<button data-au-event="signup_click" data-au-prop-plan="pro">Start</button>

Scroll goals record an event once per page view, the first time an element comes into view (data-au-scroll-threshold is the visible share needed, 0 to 1, default 0.5):

<section data-au-scroll="saw_pricing" data-au-scroll-threshold="0.3">...</section>

Events show on the Custom events page, can be funnel steps, and appear in each visitor's timeline.

Identify users

When someone signs in to your site, tell AnalyzeUser who they are. Their visits, events and purchases then show under their name in the People panel and on their profile, and a sale that arrives without a visitor id can still find its buyer by email.

window.analyzeUser.identify(user.id, {
  email: user.email,   // optional
  name: user.name,     // optional
  plan: "pro",         // up to 8 more plain values
});

// On sign-out:
window.analyzeUser.identify(null);

It sends one event the first time and again only when something changes, so calling it on every page load is fine. Only send what your privacy policy allows: what you pass is shown to you in your dashboard.

What's tracked automatically

Pageviews (including SPA navigations and back/forward restores), the referrer and UTM tags of each visit, ?ref= / ?via= / ?source= link tags, country and city, device, browser and OS, and clicks to other sites (outbound_link, named after the destination's host and path - never its query string). Bots and automated browsers are recorded as bots and left out of your numbers.

Leave out your own visits

Browsers you use the dashboard from are left out of your site's stats automatically. For a device that never opens the dashboard, visit any page of your site once with ?au_ignore=1(?au_ignore=0 undoes it). To leave out an office network, pages like your app's logged-in area, or a country, add rules under Project settings -> Exclusions (IP addresses and ranges, paths with * wildcards, country codes).

Proxy through your domain

Ad blockers drop requests to analytics domains, so a share of visitors - often a large one on a technical audience - never shows up. Serve the script and the events from your own domain and they count too. Use neutral paths (not "analytics" or "track"), then point the script tag at them with data-endpoint:

<script defer src="/au/script.js" data-site-id="YOUR_SITE_ID" data-endpoint="/au/event"></script>

Next.js on Vercel - two rewrites in next.config.js. The visitor's location carries through on Vercel; nothing else to do.

async rewrites() {
  return [
    { source: "/au/script.js", destination: "https://analyzeuser.com/track.js" },
    { source: "/au/event", destination: "https://analyzeuser.com/api/collect" },
  ];
}

Anywhere else - the request then reaches us from your server, so pass the visitor's address along in X-AnalyzeUser-Client-IP and we place them by it. A Cloudflare Worker:

export default {
  async fetch(request) {
    const url = new URL(request.url);
    if (url.pathname === "/au/script.js") return fetch("https://analyzeuser.com/track.js");
    if (url.pathname === "/au/event") {
      const headers = new Headers(request.headers);
      headers.set("X-AnalyzeUser-Client-IP", request.headers.get("CF-Connecting-IP") || "");
      return fetch("https://analyzeuser.com/api/collect", { method: "POST", headers, body: request.body });
    }
    return fetch(request);
  },
};

Nginx:

location = /au/script.js {
  proxy_pass https://analyzeuser.com/track.js;
  proxy_set_header Host analyzeuser.com;
  proxy_ssl_server_name on;
}
location = /au/event {
  proxy_pass https://analyzeuser.com/api/collect;
  proxy_set_header Host analyzeuser.com;
  proxy_ssl_server_name on;
  proxy_set_header X-AnalyzeUser-Client-IP $remote_addr;
}

AI crawlers

ChatGPT, Claude, Perplexity and other AI crawlers read your pages to answer people's questions, to build their search indexes and to train models - and almost none of them run JavaScript, so no tracking script can see them. Report them from your server: test each request's user agent and, for an AI crawler, post it to AnalyzeUser without waiting for the reply. They land in the dashboard's AI crawlers panel (split into AI answers, indexing and training) and never count as visitors or toward your plan.

Next.js - middleware.js at the project root:

import { NextResponse } from "next/server";

const AI_CRAWLERS = /ChatGPT-User|ChatGPT Agent|ChatGPT-Agent|OAI-SearchBot|GPTBot|Claude-User|Claude-SearchBot|ClaudeBot|anthropic-ai|claude-web|Perplexity-User|PerplexityBot|Gemini-Deep-Research|Google-Gemini|Google-CloudVertexBot|GoogleOther|DuckAssistBot|MistralAI-User|meta-externalfetcher|meta-externalagent|FacebookBot|YouBot|Applebot|Amazonbot|Bytespider|CCBot|cohere-ai|cohere-training-data-crawler|AI2Bot|Diffbot|PetalBot/i;

export function middleware(request, event) {
  const ua = request.headers.get("user-agent") || "";
  if (AI_CRAWLERS.test(ua)) {
    event.waitUntil(
      fetch("https://analyzeuser.com/api/crawl", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ site_id: "YOUR_SITE_ID", path: request.nextUrl.pathname, user_agent: ua }),
      }).catch(() => {})
    );
  }
  return NextResponse.next();
}

export const config = { matcher: "/((?!_next|api|favicon.ico).*)" };

Cloudflare Worker (or any server): the same test, then the same request. Batches of up to 50 hits go in one call as { "site_id": "...", "hits": [{ "path", "user_agent" }] }.

if (AI_CRAWLERS.test(ua)) {
  ctx.waitUntil(fetch("https://analyzeuser.com/api/crawl", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ site_id: "YOUR_SITE_ID", path: new URL(request.url).pathname, user_agent: ua }),
  }));
}

Content Security Policy

If your site sends a Content-Security-Policy header, allow the script and the endpoint it posts to (not needed when you proxy through your own domain):

script-src 'self' https://analyzeuser.com;
connect-src 'self' https://analyzeuser.com;

A blocked script shows as a CSP error in the browser console and no visits in the dashboard. The script adds no inline code and sets no cookies.

Use fewer events

Every pageview and custom event counts toward your plan. Outbound link clicks are on by default (a few per hundred pageviews); turn them off with data-track-outbound="false". Clicks on every link and button are off unless you set data-track-clicks="true" - prefer a handful of named events for what matters. Leave out pages you don't need counted (an app's logged-in area, admin pages) under Project settings -> Exclusions. Bots and your own visits never count.

Revenue attribution

Connect Stripe, Dodo Payments, Lemon Squeezy or Razorpay in your project settings and each sale is credited to the visit that brought the buyer. Stripe and Dodo payment links, and Razorpay Checkout, are tagged automatically. For checkouts you create on your server, pass the visitor id in the payment's metadata as au_visitor_id:

const visitorId = window.analyzeUser.getVisitorId(); // send this to your server
// Stripe:   metadata: { au_visitor_id: visitorId }
// Dodo:     metadata: { au_visitor_id: visitorId }
// Razorpay: notes:    { au_visitor_id: visitorId }

REST API

Create a personal access token on the MCP page of your account (the same token works for MCP and the API) and send it as a bearer token. Keep it on your server - never in a browser. Up to 60 requests a minute; range is one of today, yesterday, 24h, 7d, 30d, 90d, wtd, mtd, lifetime.

curl https://analyzeuser.com/api/v1/sites/SITE_ID/stats?range=30d \
  -H "Authorization: Bearer au_mcp_..."
GET/api/v1/sitesYour sites, with their ids and domains.
GET/api/v1/sites/:id/statsVisitors, pageviews, bounce rate, session time, vs the previous period.
GET/api/v1/sites/:id/pagesTop pages by visitors (?limit=1-100).
GET/api/v1/sites/:id/sourcesChannels and referrers, AI engines included.
GET/api/v1/sites/:id/revenueRevenue by source and channel.
GET/api/v1/sites/:id/locationsCountries and cities.
GET/api/v1/sites/:id/devicesDevices, browsers and operating systems.
GET/api/v1/sites/:id/exit-pagesWhere visits end.
GET/api/v1/sites/:id/reportAll of the above in one call.
GET/api/v1/sites/:id/timeseriesVisitors, pageviews, events and revenue per hour, day, week or month (?interval=).
GET/api/v1/sites/:id/realtimeWho's on the site right now: count, last 30 minutes, sources, countries.
GET/api/v1/sites/:id/campaignsUTM campaigns by visitors.
GET/api/v1/sites/:id/goalsYour custom events: visitors, completions and conversion rate.
GET/api/v1/sites/:id/funnelsYour saved funnels with each step's visitors.
GET/api/v1/sites/:id/notesChart notes (?from=&to= as YYYY-MM-DD).
POST/api/v1/sites/:id/notesAdd a chart note: { "date": "2026-11-09", "text": "Launched on Product Hunt" }.
POST/api/v1/sites/:id/paymentsReport a sale (Payment API).

Responses are { "data": ... }; errors are { "error": { "code", "message" } } with a 401 (no or bad token), 402 (trial or subscription ended), 403 (not your site) or 429 (rate limit).

Payment API

Report sales from any checkout - your own billing, a provider we don't connect to, a mobile app. The sale is credited to the buyer's visit like any connected provider's: by visitor_id when you send it, else by email when it appears in a tracked event. Sending the same transaction_idagain updates the sale (for example to mark it refunded).

curl -X POST https://analyzeuser.com/api/v1/sites/SITE_ID/payments \
  -H "Authorization: Bearer au_mcp_..." \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_id": "order_1042",
    "amount": 59.00,
    "currency": "usd",
    "visitor_id": "vis_...",
    "customer_email": "buyer@example.com",
    "paid_at": "2026-11-09T10:00:00Z"
  }'

amount is in major units (or send amount_cents in minor units); paid_at defaults to now and also accepts a unix timestamp; refunded: true marks a refund; subscription_id groups renewals with the payment that started the subscription.