/v1/ai-traffic
AI traffic endpoints measure how many visitors reach your site from AI assistants like ChatGPT, Perplexity, Claude, and Gemini. Pair these routes with the lightweight tracking script (or a connected Google Analytics property) to power custom dashboards and reporting.
These routes are available on the public API using your
api-key header, the same as every other /v1 endpoint. See the REST API overview for authentication and plan eligibility.How tracking works
- Create a tracking site to get a
siteKeyand a ready-to-paste script snippet. - Install the snippet on every page you want to measure (before
</head>). - Query
GET /v1/ai-traffic/statsto read aggregated AI traffic.
GET /sites
List the tracking sites in your workspace.
POST /sites
Create a new tracking site. Returns the site with its generated siteKey and install snippet.
Body:
POST /sites/ensure
Ensure a default tracking site exists for the workspace. Useful when bootstrapping — it returns the existing site, creates one when possible, or signals that a domain is still required.
POST /sites:
GET /stats
Fetch aggregated AI traffic for a tracking site.
Query parameters:
daily, sources, and topPages are omitted and restricted is true:
Stats data model
Exact field names may vary by API version. Treat responses as the source of truth for your integration.
Google Analytics as a data source
Instead of the tracking script, you can pull AI traffic from a connected GA4 property. Connecting Google Analytics uses an OAuth flow completed in the Krastie app; once connected, these endpoints manage and read the integration.The OAuth connection step (
/v1/integrations/google-analytics/auth) is a browser redirect and is completed in the app, not via the API.domain to match by site URL and autoSelect=1 to auto-pick a matching property:
"source": "google_analytics":
Workflow example
Related endpoints
- AI visibility endpoints — Measure mentions and citations in AI answers
- Chat sessions — Assistant with visibility and traffic context