Skip to main content
POST
/
api
/
analytics.query
Execute an analytics query
curl --request POST \
  --url https://your-instance.example.com/api/analytics.query \
  --header 'Content-Type: application/json' \
  --data '
{
  "workspace_id": "<string>",
  "metrics": [
    "<string>"
  ],
  "dateRange": {
    "start": "<string>",
    "end": "<string>",
    "preset": "previous_30_minutes",
    "granularity": "hour"
  },
  "dimensions": [
    "<string>"
  ],
  "filters": [
    {
      "dimension": "<string>",
      "operator": "equals",
      "values": [
        {}
      ]
    }
  ],
  "metricFilters": [
    {
      "metric": "<string>",
      "operator": "gt",
      "values": [
        {}
      ]
    }
  ],
  "compareDateRange": {
    "start": "<string>",
    "end": "<string>",
    "preset": "previous_30_minutes",
    "granularity": "hour"
  },
  "timezone": "<string>",
  "order": {},
  "limit": 5000.5,
  "havingMinSessions": 2,
  "table": "sessions",
  "totalsGroupBy": [
    "<string>"
  ]
}
'
{}

Body

application/json
workspace_id
string
required
metrics
string[]
required
Minimum array length: 1
dateRange
object
required
dimensions
string[]
filters
object[]
metricFilters
object[]
compareDateRange
object
timezone
string
order
object
limit
number
Required range: 1 <= x <= 10000
havingMinSessions
number
Required range: x >= 1
table
enum<string>
Available options:
sessions,
pages,
goals
totalsGroupBy
string[]

When set, enables "filtered totals" mode for queries with no dimensions. The query will:

  1. Group by these dimensions in an inner subquery
  2. Apply metricFilters via HAVING clause
  3. Aggregate the filtered results in an outer query

Use this for totals that should respect metricFilters. Example: Get total sessions where bounce_rate > 50%, grouped by landing_path.

Response

200 - application/json

The response is of type object.