Analytics API

Access consent analytics for your sites, including consent rates, daily trends, and geographic breakdowns.

Query Parameters

All analytics endpoints accept these query parameters:

Name Type Required Default Description
period string No 30d Time range: 7d, 30d, 90d, or custom
from string No - Start date (YYYY-MM-DD). Required when period=custom
to string No - End date (YYYY-MM-DD). Required when period=custom

Endpoints

GET /api/v1/sites/:siteId/analytics Get analytics overview

Returns an aggregated overview and daily breakdown for the specified period. Rates are percentages (0-100). The daily array contains one entry per day within the range.

Response

{
"period": "30d",
"overview": {
  "totalImpressions": 15420,
  "consentRate": 72,
  "acceptAllRate": 58,
  "rejectAllRate": 28,
  "customRate": 14,
  "categoryRates": {
    "analytics": 65,
    "marketing": 42,
    "functional": 71
  }
},
"daily": [
  {
    "date": "2026-01-18",
    "impressions": 512,
    "accept_all": 298,
    "reject_all": 143,
    "custom_consent": 71,
    "analytics_consent_rate": 66.2,
    "marketing_consent_rate": 43.5,
    "functional_consent_rate": 72.1
  }
]
}
GET /api/v1/sites/:siteId/analytics/geo Get geographic breakdown

Returns consent metrics broken down by country (ISO 3166-1 alpha-2 codes). Up to 50 countries, sorted by impressions descending.

Response

{
"period": "30d",
"countries": [
  {
    "country": "DE",
    "impressions": 3240,
    "acceptAll": 1890,
    "rejectAll": 972,
    "customConsent": 378,
    "consentRate": 70
  },
  {
    "country": "US",
    "impressions": 2180,
    "acceptAll": 1744,
    "rejectAll": 218,
    "customConsent": 218,
    "consentRate": 90
  }
]
}
GET /api/v1/sites/:siteId/analytics/export Export analytics as CSV

Returns daily analytics as a CSV file. The response Content-Type is text/csv with a Content-Disposition header for download.

Response

date,impressions,accept_all,reject_all,custom_consent,analytics_rate,marketing_rate,functional_rate
2026-01-18,512,298,143,71,66.2,43.5,72.1
2026-01-19,487,284,136,67,65.8,42.1,70.5

Example: custom date range

curl "https://api.cookieboss.io/api/v1/sites/$SITE_ID/analytics?period=custom&from=2026-01-01&to=2026-01-31" \
  -H "Authorization: Bearer $TOKEN"

Maximum range

Custom date ranges cannot exceed 365 days. Requests with longer ranges return a 400 error.