Skip to main content
Base path: /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.
Detailed analytics — AI sources, traffic over time, and top pages — are available on paid plans. On free plans these fields are omitted and responses include "restricted": true. Summary totals remain available. See the pricing page.

How tracking works

  1. Create a tracking site to get a siteKey and a ready-to-paste script snippet.
  2. Install the snippet on every page you want to measure (before </head>).
  3. Query GET /v1/ai-traffic/stats to read aggregated AI traffic.
The snippet looks like this:
As an alternative to the script tag, you can connect Google Analytics as the data source — see Google Analytics as a data source.

GET /sites

List the tracking sites in your workspace.
Response (200):

POST /sites

Create a new tracking site. Returns the site with its generated siteKey and install snippet. Body:
Response (200):

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.
Response (200):
When no domain is known yet, the response asks you to create a site with POST /sites:

GET /stats

Fetch aggregated AI traffic for a tracking site. Query parameters:
Response (200):
On free plans, 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.
Connection status:
List properties. Pass domain to match by site URL and autoSelect=1 to auto-pick a matching property:
Select a property:
Read GA4 stats. Returns the same stats data model with "source": "google_analytics":

Workflow example