# Checkend for agents

Checkend is privacy-friendly web analytics (no cookies). It counts visitors, visits, pageviews and
custom events of the user's web sites. Use it to answer questions about traffic, sources, pages and
events, to check the effect of a change, and to record the changes you make.

Auth: send the token the user gave you as `Authorization: Bearer ck_...`. Read-only tokens can call
every read operation; `record_change`, `rename_event`, `create_funnel` and `delete_funnel` need a token
with the write scope.

## MCP (preferred)

Streamable HTTP at `https://app.checkend.com/mcp`. Claude Code:

    claude mcp add --transport http checkend https://app.checkend.com/mcp --header "Authorization: Bearer <token>"

Tools: `list_sites`, `query`, `list_events`, `event_properties`, `funnel`, `list_funnels`, `create_funnel`, `delete_funnel`, `list_changes`, `record_change`, `rename_event`.

## HTTP

    curl -s https://app.checkend.com/api/v1/query -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
      -d '{"site":"example.com","metrics":["visitors","pageviews"],"period":"7d","dimensions":["source"],"limit":20}'

Answer: `{"rows": [{"source": "Google", "visitors": 262, "pageviews": 300}], "meta": {"from": "...", "to": "..."}}`

Body fields:

| Field | Values |
|---|---|
| site | domain (`example.com`) or site id |
| metrics | visitors, visits, pageviews, events, bounce_rate (%), visit_duration (s). Default visitors |
| period | realtime (30 min), today, 24h, 7d, 28d, 30d, 90d, 12m, custom (+ from, to as YYYY-MM-DD). Default 28d. Nd = the last N days including today, in the site timezone |
| dimensions | up to 3 of: source, source_type, referrer, utm_source, utm_medium, utm_campaign, utm_content, utm_term, page, entry_page, exit_page, country (ISO code), region, city, device, browser, os, event, prop:<name> |
| filters | `[{"dim": "source", "op": "is", "value": "Google"}]`; op is, is_not, contains; dim any dimension |
| interval | minute, hour, day, week, month: adds a `date` column (time series; a week starts on the org's first day of the week) |
| limit | max rows, default 100 |

Notes:
- 402 `payment_required` means that the trial or the plan ended. Tell the user: an owner can choose a plan in
  Settings › Billing. Do not try again before that.
- source_type is one of direct, search, social, ai, email, paid, other. AI assistants (chatgpt.com,
  perplexity.ai, claude.ai, ...) are their own source type.
- event, prop and page dimensions count single events: bounce_rate and visit_duration are not available with them.
- An event or prop filter keeps the visits that contain a matching event.
- Event names may have aliases (merge, rename, hide); queries show the final names.

## Funnels

`funnel` runs a stored funnel (id or name) or ad hoc steps. To make a funnel show on the dashboard, store it
with `create_funnel` (site, name, 2 to 8 steps). A step is `{"type": "page", "value": "/pricing"}`
(`*` = any page) or `{"type": "event", "value": "Signup"}`. Check the event names with `list_events` first.
Names are unique per site. Over HTTP: `GET https://app.checkend.com/api/v1/funnels?site=example.com`,
`POST https://app.checkend.com/api/v1/funnels` with `{"site", "name", "steps"}`, and
`DELETE https://app.checkend.com/api/v1/funnels/{id or name}?site=example.com`.

## Export (raw data)

One file of one site at once, CSV or Parquet, at most 366 days per call (split longer ranges):

    curl -s "https://app.checkend.com/api/v1/export?site=example.com&from=2026-10-01&to=2026-10-31&kind=events&format=csv" \
      -H "Authorization: Bearer <token>" -o events.csv

`kind=events` gives every pageview and custom event (timestamp in UTC, name as sent with no aliases, page,
source, UTM, location, device, `props` as JSON, `session_id`; no visitor id). `kind=stats` gives one row per
day: date, visitors, visits, pageviews, views_per_visit, bounce_rate, visit_duration. `from` and `to` are days
in the site timezone. Use `query` for aggregates; use the export only for raw rows or a full copy.

## Recording a change

When you change a site (copy, layout, a new event), record it with `record_change`
(site, text, optional ts in RFC 3339 and the metric to watch, e.g. `event:Signup`). It shows as a marker
on the chart, and after 3 days Checkend compares the metric in the days after with the days before.

## Event names

`list_events` shows name problems: duplicates (ArticleViewed = Biller Article Viewed), names of another
site, and mixed naming styles, each with a fix. Apply a fix with `rename_event` (from, to) only when the
user agrees. Raw events are never changed; a rename can be undone in the UI.

## Public dashboard

A site owner can make a public stats page and badge in the site settings. No tool and no API call turns it on
or changes it: making data public is the owner's decision in the UI.

## Tracking

Pages add `<script defer data-domain="example.com" src="https://app.checkend.com/s.js"></script>`.
Custom events: `window.checkend('Signup', {props: {plan: 'pro'}})` (`window.plausible` works too), or
HTML attributes `data-ck="Signup" data-ck-plan="pro"` on a clickable element. Use Title Case names.
