GitBook API API reference Docs sitesSite insights Analyze traffic and engagement metrics for your docs site.
This API delivers insights about how visitors interact with your site, including page views and user engagement, helping you measure and optimize your content strategy.
Track site events
post
https://api.gitbook.com/v1 /orgs/ {organizationId} /sites/ {siteId} /insights/events
organizationId string Required The unique id of the organization
siteId string Required The unique id of the site
Copy POST /v1/orgs/{organizationId}/sites/{siteId}/insights/events HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 453
{
"events": [
{
"session": {
"visitorId": "text",
"sessionId": "text",
"cookies": {
"ANY_ADDITIONAL_PROPERTY": "text"
},
"ip": "text",
"userAgent": "text",
"language": "text",
"referrer": null,
"visitorAuthClaims": {
"ANY_ADDITIONAL_PROPERTY": "[Circular Reference]"
}
},
"location": {
"url": "https://example.com",
"siteSection": "text",
"siteSpace": "text",
"siteShareKey": "text",
"space": "text",
"revision": "text",
"page": "text"
},
"timestamp": "2025-04-20T22:08:26.976Z",
"type": "page_view"
}
]
}
Query site events
post
https://api.gitbook.com/v1 /orgs/ {organizationId} /sites/ {siteId} /insights/events/aggregate
organizationId string Required The unique id of the organization
siteId string Required The unique id of the site
range string · enum Required Available options: lastYear
last3Months
last30Days
last7Days
last24Hours
limit integer · min: 1 · max: 1000 Optional Default: 1000
Copy POST /v1/orgs/{organizationId}/sites/{siteId}/insights/events/aggregate HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 294
{
"select": [
{
"column": "datetime",
"interval": "hour"
}
],
"where": [
{
"column": "datetime",
"values": [
"2025-04-20T22:08:26.976Z"
]
},
{
"operator": "in"
}
],
"groupBy": [
{
"column": "datetime",
"interval": "hour"
}
],
"order": {
"by": {
"column": "datetime",
"interval": "hour"
},
"direction": "asc"
},
"range": "lastYear",
"limit": 1
}
List a site visitor segments
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /sites/ {siteId} /insights/visitor-segments
organizationId string Required The unique id of the organization
siteId string Required The unique id of the site
Copy GET /v1/orgs/{organizationId}/sites/{siteId}/insights/visitor-segments HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*