Skip to content

analytics_metric_query

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time.

Tool

analytics_metric_query

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time.

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time. Supply group_by to split each time bucket by one dimension; omit it to aggregate without dimension grouping. Deterministic: entity, metric and dimension names are resolved against the semantic catalog, never generated. Prefer this over analytics_query_run whenever the question is a metric over time — no LLM. Where the catalog gives an entity a `propertiesColumn`, `group_by` and a filter dimension also accept `props.<key>` to read one raw event property; property values always compare as strings. Filters support legacy {dimension, eq} or op eq, neq, in, not_in, starts_with, is_null, is_not_null; in and not_in take 1–100 values of one type; starts_with takes a string and works on text dimensions. neq and not_in retain NULL rows.

Behavior

HTTP
POST /analytics/metrics/query

Arguments

Name
Type
Required
Description
to
string
•
Inclusive last day (UTC)
from
string
•
Inclusive first day (UTC)
grain
string
•
Time bucket size
entity
string
•
Semantic view name from the catalog
filters
array
—
Filters on declared dimensions or `props.<key>`: legacy eq, or op eq, neq, in, not_in (1–100 values of one type), starts_with (string value on text dimensions), is_null, is_not_null. neq and not_in retain NULL rows.
metrics
array
•
Declared metric names to compute. A metric of type `count_distinct` must be the only one: request it separately
group_by
string
—
One declared dimension, or `props.<key>`, to group by
person_filter
string
—
`exclude_identified` drops the rows of identified people: a person who has an email or a phone in the analytics person graph. The link is the row's identifier, not time, so a visitor's earlier anonymous rows are dropped too once that visitor is identified. Rows with no identifier (cookieless events) are never excluded, because there is nothing to resolve them by. The person graph is rebuilt on a schedule (hourly by default), so a newly identified person is excluded only after the next rebuild. Omit the field to count everyone.

Response

Field
Type
Always
Description
meta
object
•
series
array
•

Try it

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time.

When to use

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time. Supply group_by to split each time bucket by one dimension; omit it to aggregate without dimension grouping. Deterministic: entity, metric and dimension names are resolved against the semantic catalog, never generated. Prefer this over analytics_query_run whenever the question is a metric over time — no LLM. Where the catalog gives an entity a `propertiesColumn`, `group_by` and a filter dimension also accept `props.<key>` to read one raw event property; property values always compare as strings. Filters support legacy {dimension, eq} or op eq, neq, in, not_in, starts_with, is_null, is_not_null; in and not_in take 1–100 values of one type; starts_with takes a string and works on text dimensions. neq and not_in retain NULL rows.

Example

Ask your agent something like this:

Compute declared metrics from the analytics semantic layer for the current product, bucketed by time.

The agent will invoke analytics_metric_query with these arguments:

{
  "to": "<to>",
  "from": "<from>",
  "grain": "<grain>",
  "entity": "<entity>",
  "metrics": "<metrics>"
}

Esc

Start typing to search the docs.

↑↓navigate↵select