Cohort Analysis API

Create and analyze user cohorts and retention

Cohort Analysis API

Create cohorts and track user retention metrics.

Create Cohort

POST /api/v1/cohorts

Request:

{
  "site_id": "site_abc123",
  "name": "Premium Users",
  "description": "Users who purchased premium plan",
  "criteria": {
    "type": "and",
    "conditions": [
      {
        "property": "event_type",
        "operator": "equals",
        "value": "purchase"
      },
      {
        "property": "plan",
        "operator": "equals",
        "value": "premium"
      }
    ]
  }
}

Get Cohort Analysis

GET /api/v1/analytics/cohorts?site_id=site_abc123&cohort_id=cohort_xyz&weeks=13

Response:

{
  "success": true,
  "data": {
    "cohort_id": "cohort_xyz",
    "site_id": "site_abc123",
    "cohort_name": "Premium Users",
    "size": 1234,
    "retention_by_week": [
      {
        "week": 0,
        "retention_rate": 100.0,
        "cohort_size": 1234,
        "returning_users": 1234
      },
      {
        "week": 1,
        "retention_rate": 87.5,
        "cohort_size": 1234,
        "returning_users": 1078
      }
    ]
  }
}

List Cohorts

GET /api/v1/cohorts?site_id=site_abc123&limit=10&offset=0

Retention Matrix

GET /api/v1/analytics/retention?site_id=site_abc123&weeks=13

Next Steps

Last updated: April 3, 2026