Web Analytics

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

Endpoints

POST
GET
GET
POST
POST
POST

Create web analytics achievements acknowledge

Clears a pending celebration for the given track and stage once the client has shown it, so it isn't celebrated again. Idempotent.

Request parameters

  • track_key
    string
  • stage
    integer

Response


Example request

POST /api/projects/:project_id/web_analytics_achievements/acknowledge_celebration
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_achievements/acknowledge_celebration/\
-d track_key="string",\
-d stage="integer"

Example response

Status 200
RESPONSE
{
"acknowledged": true
}

Retrieve web analytics achievements

Returns the achievement track definitions (thresholds resolved for the requesting user's streak-cadence arm), the user's and team's progress, and any newly unlocked stages awaiting an in-session celebration.

Response


Example request

GET /api/projects/:project_id/web_analytics_achievements/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_achievements/overview/

Example response

Status 200
RESPONSE
{
"definitions": [
{
"key": "string",
"display_name": "string",
"description": "string",
"scope": "user",
"is_experiment_track": true,
"stages": [
{
"stage": 0,
"name": "string",
"threshold": 0
}
]
}
],
"user_progress": [
{
"track_key": "string",
"current_stage": 0,
"progress_value": 0,
"last_computed_at": "2019-08-24T14:15:22Z",
"unlocked_at": {
"property1": "2019-08-24T14:15:22Z",
"property2": "2019-08-24T14:15:22Z"
}
}
],
"team_progress": [
{
"track_key": "string",
"current_stage": 0,
"progress_value": 0,
"last_computed_at": "2019-08-24T14:15:22Z",
"unlocked_at": {
"property1": "2019-08-24T14:15:22Z",
"property2": "2019-08-24T14:15:22Z"
}
}
],
"pending_celebrations": [
{
"track_key": "string",
"stage": 0,
"stage_name": "string"
}
]
}

Retrieve web analytics achievements

Returns the requesting user's per-project Web analytics achievements preferences.

Response


Example request

GET /api/projects/:project_id/web_analytics_achievements/preferences
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_achievements/preferences/

Example response

Status 200
RESPONSE
{
"achievements_opt_out": true
}

Create web analytics achievements update

Sets the requesting user's per-project Web analytics achievements preferences.

Request parameters

  • achievements_opt_out
    boolean

Response


Example request

POST /api/projects/:project_id/web_analytics_achievements/preferences
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_achievements/preferences/\
-d achievements_opt_out="boolean"

Example response

Status 200
RESPONSE
{
"achievements_opt_out": true
}

Create web analytics achievements record

Idempotently increments the requesting user's first-party counter for an in-product Web analytics interaction (slicing data, or opening a session recording), which drives the Explorer and Detective achievement tracks.

Request parameters

  • interaction_kind

Response


Example request

POST /api/projects/:project_id/web_analytics_achievements/record_interaction
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_achievements/record_interaction/\
-d interaction_kind=undefined

Example response

Status 200
RESPONSE
{
"recorded": true
}

Create web analytics achievements record

Idempotently records that the requesting user opened Web analytics today (team-local date) and schedules a debounced achievement recompute. Intended to be called once per session.

Response


Example request

POST /api/projects/:project_id/web_analytics_achievements/record_visit
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_achievements/record_visit/

Example response

Status 200
RESPONSE
{
"recorded": true
}

Community questions