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.

<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)

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.

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).

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.
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.