Web analytics

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
GET

Retrieve web analytics breakdown

Required API key scopes

query:read

Path parameters

  • project_id
    string

Query parameters

  • apply_path_cleaning
    boolean
    Default: true
  • breakdown_by
    string
    One of: "DeviceType""Browser""OS""Viewport""InitialReferringDomain""InitialUTMSource""InitialUTMMedium""InitialUTMCampaign""InitialUTMTerm""InitialUTMContent""Country""Region""City""InitialPage""Page""ExitPage""InitialChannelType"
  • date_from
    string
  • date_to
    string
  • filter_test_accounts
    boolean
    Default: true
  • host
    string
  • limit
    integer
    Default: 100
  • offset
    integer
    Default: 0

Response


Example 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/

Example response

Status 200 Get a breakdown of web analytics data by supported properties.
RESPONSE
{
"next": "https://us.posthog.com/api/web_analytics/breakdown?offset=2&limit=2",
"results": [
{
"breakdown_value": "/home",
"visitors": 8500,
"views": 12000,
"sessions": 9200
},
{
"breakdown_value": "/about",
"visitors": 2100,
"views": 2800,
"sessions": 2300
}
]
}

Retrieve web analytics overview

This endpoint is in Concept state, please join the feature preview to try it out when it's ready. Get an overview of web analytics data including visitors, views, sessions, bounce rate, and session duration.

Required API key scopes

query:read

Path parameters

  • project_id
    string

Query parameters

  • date_from
    string
  • date_to
    string
  • filter_test_accounts
    boolean
    Default: true
  • host
    string

Response


Example 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/

Example response

Status 200 Get simple overview metrics: visitors, views, sessions, bounce rate, session duration
RESPONSE
{
"visitors": 12500,
"views": 45000,
"sessions": 18200,
"bounce_rate": 0.32,
"session_duration": 185.5
}

Community questions

Questions about this page? or post a community question.