Web analytics
For instructions on how to authenticate to use this endpoint, see API overview.
Get a breakdown by a property (e.g. browser, device type, country, etc.). This endpoint is in beta, please contact support to enable it for your team.
Endpoints
Retrieve web analytics breakdown
Required API key scopes
query:read
Path parameters
- project_idstring
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
Query parameters
- apply_path_cleaningbooleanDefault:
true
Apply URL path cleaning
- breakdown_bystringOne of:
"DeviceType"
"Browser"
"OS"
"Viewport"
"InitialReferringDomain"
"InitialUTMSource"
"InitialUTMMedium"
"InitialUTMCampaign"
"InitialUTMTerm"
"InitialUTMContent"
"Country"
"Region"
"City"
"InitialPage"
"Page"
"ExitPage"
"InitialChannelType"
Property to break down by
DeviceType
- DeviceTypeBrowser
- BrowserOS
- OSViewport
- ViewportInitialReferringDomain
- InitialReferringDomainInitialUTMSource
- InitialUTMSourceInitialUTMMedium
- InitialUTMMediumInitialUTMCampaign
- InitialUTMCampaignInitialUTMTerm
- InitialUTMTermInitialUTMContent
- InitialUTMContentCountry
- CountryRegion
- RegionCity
- CityInitialPage
- InitialPagePage
- PageExitPage
- ExitPageInitialChannelType
- InitialChannelType
- date_fromstring
Start date for the query (format: YYYY-MM-DD)
- date_tostring
End date for the query (format: YYYY-MM-DD)
- filter_test_accountsbooleanDefault:
true
Filter out test accounts
- hoststring
Host to filter by (e.g. example.com)
- limitintegerDefault:
100
Number of results to return
- offsetintegerDefault:
0
Number of results to skip
Response
Request
GET
/api /projects /:project_id /web_analytics /breakdown
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/projects/:project_id/web_analytics/breakdown/
Response
Status 200 Get a breakdown of web analytics data by supported properties.
{"count": 25,"next": "https://us.posthog.com/api/web_analytics/breakdown?offset=2&limit=2","previous": null,"results": [{"breakdown_value": "/home","visitors": 8500,"views": 12000,"sessions": 9200},{"breakdown_value": "/about","visitors": 2100,"views": 2800,"sessions": 2300}]}
Retrieve web analytics overview
Get an overview of web analytics data including visitors, views, sessions, bounce rate, and session duration. This endpoint is in beta, please contact support to enable it for your team.
Required API key scopes
query:read
Path parameters
- project_idstring
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
Query parameters
- date_fromstring
Start date for the query (format: YYYY-MM-DD)
- date_tostring
End date for the query (format: YYYY-MM-DD)
- filter_test_accountsbooleanDefault:
true
Filter out test accounts
- hoststring
Host to filter by (e.g. example.com)
Response
Request
GET
/api /projects /:project_id /web_analytics /overview
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/projects/:project_id/web_analytics/overview/
Response
Status 200 Get simple overview metrics: visitors, views, sessions, bounce rate, session duration
{"visitors": 12500,"views": 45000,"sessions": 18200,"bounce_rate": 0.32,"session_duration": 185.5}