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
events one of[] Required
Show available items
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-05-14T01:51:39.262Z",
"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
select one of[] Optional
Show available items
where all of[] Optional
Show all of
groupBy one of[] Optional
Show available items
order object Optional
Show properties
range string · enum Required Allowed values: lastYear
last3Months
last30Days
last7Days
last24Hours
limit integer · min: 1 · max: 1000 Optional Default: 1000
object Optional
Show properties
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-05-14T01:51:39.262Z"
]
},
{
"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
all of Optional
object Optional
Show properties
Copy GET /v1/orgs/{organizationId}/sites/{siteId}/insights/visitor-segments HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*