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
| Type | When to fire |
|---|---|
| PAGE_VIEW | Page loaded |
| READ | User scrolled past 80% |
| CLICK | CTA or link clicked |
| SHARE | Share button clicked |
| CONVERSION | Custom 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 }]
}
}