Analytics API

Track events and retrieve workspace analytics.

Track an Event

POST /api/v1/analytics
x-workspace-id: clxxx

{
  "type": "PAGE_VIEW",
  "blogId": "clyyy",
  "sessionId": "sess_abc",
  "referrer": "https://google.com",
  "device": "desktop",
  "country": "US"
}

Event Types

TypeWhen to fire
PAGE_VIEWPage loaded
READUser scrolled past 80%
CLICKCTA or link clicked
SHAREShare button clicked
CONVERSIONCustom goal met

Get Workspace Stats

GET /api/v1/analytics?days=30

Response:
{
  "data": {
    "totalViews": 12450,
    "totalReaders": 8320,
    "topPosts": [...],
    "viewsByDay": [{ "date": "2024-01-01", "views": 450 }]
  }
}