Skip to main content
Glama

Event query

run_insights_query
Read-onlyIdempotent

Count events or sum/average a numeric detail by day/week/month/hour, filtered, split by a property (top 10; table 100) or as 1-4 series (A-D); compare_previous adds the change vs the prior period. Counts events, not visitors. Use summary_total or a series' total. Non-numbers skipped: say if left_out set. Buckets marked partial cover only part of their week/month/year (see covers_from/covers_to) or contain today: never read a partial bucket as a drop. By hour: the current hour is incomplete, later hours read 0. Dates are the project's calendar days, YYYY-MM-DD (timezone: get_project); timestamps are UTC. Omit from/to for the last 28 complete days, ending yesterday. A period marked starts_before_data begins before the project has data (see data_from): those days read as zero, not as a quiet period. Quote counts with every percentage; a big change on a small count is noise, not a finding.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "run_insights_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoLast day, YYYY-MM-DD in the project's timezone, inclusive. Default: yesterday, the last complete day.
fromNoFirst day, YYYY-MM-DD in the project's timezone, inclusive. Default: 27 days before 'to'.
labelNoOptional short name of the query's one series as a chart shows it, at most 60 characters (e.g. Revenue). With series, give each series its label instead.
limitNoWith a breakdown: how many top values, 1-10 (default 10), up to 100 with visualization table.
seriesNoInstead of measure, measure_property, event_type, filters and label (not together): 1 to 4 series compared in one chart on the same buckets, keyed A, B, C, D in order, each with its own measure, measure_property, event_type, filters and label. Each series counts exactly what the same query alone would. Several series take no breakdown; their totals are in result.series, and summary_total is then null.
filtersNoFilters. Every item must hold (AND); an item is one filter (property, operator, value) or an any group of filters of which at least one must hold (OR), e.g. [{property: data_track, operator: equals, value: checkout}, {any: [{property: page_path, operator: equals, value: /pricing}, {property: page_path, operator: equals, value: /plans}]}].
measureNoevents (default): count the matching events. sum or average: add up or average measure_property, per event, over the matching events whose value is a number: a numeric event detail, or a page view's scroll_depth (average only) or time_on_page_seconds. Values that are not numbers are left out and counted in non_numeric_events; an average bucket with no numbers is null, not 0.
projectNoProject ID, from list_projects. Required when this connection covers more than one project; may be left out when it covers one (and with an API key, which belongs to one project).
sort_byNoWith a breakdown: the series (A, B, C or D) the rows are ordered by, highest first. In a table the rows are every value any series has among its own top limit, so a value only one series has is a row (0, or null for a sum or average, in the others). Default A.
group_byNoBucket size: day (default), week, month or hour. hour needs a range of at most 31 days, from and to both included; its points are the hours of the project's timezone (23 or 25 on a day the clocks change), each with date (its day) and start (the hour with the project's UTC offset).
breakdownNoSplit by a property (same names as filters, or event_type; automated splits into true and false; scroll_depth and time_on_page_seconds cannot be a breakdown); query.utm_source, query.utm_medium and query.ref group lower-cased. Only the top 10 groups are returned: the most events, the largest sums, or for average the groups with the most numbers. For events and sum use summary_total as the denominator; for average summary_total is the average over all events with a number, each event once.
event_typeNoOnly this event type: pageview, click, form_submit, custom, dead_click, rage_click, error_click or slow_click (friction signals: a click after which nothing happened, a burst of rapid clicks, a click followed by an uncaught error, a click that took long to show any effect; never part of a feature). Omit for all.
visualizationNoOnly table changes the answer: with a breakdown, several series may then have one, as rows (result.table: one row per detail value or other breakdown value, a column per series), and limit may be up to 100. Omit otherwise.
compare_previousNoAlso return each series' value over the previous period (the equally long run of days right before from..to) and the change, in comparison (on the result, or on each of result.series): what a single-value widget (visualization number) shows. No breakdown with it. When the previous period starts before the project's data there is no change: say so instead of comparing.
measure_propertyNoFor sum and average only, and then required: the event detail to read, attrs.KEY (e.g. attrs.order_value for track('Purchase', { order_value: 34.5 })), or scroll_depth (average only) or time_on_page_seconds: a page view's scroll depth in percent (0-100) and its active seconds (0-1800); only page views with a value take part (null means no value arrived, never 0), and a page_path filter narrows it to one page. list_property_keys lists the keys; filter to the event that carries a detail (e.g. data_track equals Purchase). A number is plain decimal text such as 34.5 or -2: '34,50', '€34' and '1e3' are not numbers.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changed
    • changedInput schema / properties / breakdown / description
      Previous value: -"Split by a property (same names as filters, or event_type; automated splits into true and false); query.utm_source, query.utm_medium and query.ref group lower-cased. Only the top 10 groups are returned: the most events, the largest sums, or for average the groups with the most numbers. For events and sum use summary_total as the denominator; for average summary_total is the average over all events with a number, each event once."New value: +"Split by a property (same names as filters, or event_type; automated splits into true and false; scroll_depth and time_on_page_seconds cannot be a breakdown); query.utm_source, query.utm_medium and query.ref group lower-cased. Only the top 10 groups are returned: the most events, the largest sums, or for average the groups with the most numbers. For events and sum use summary_total as the denominator; for average summary_total is the average over all events with a number, each event once."
    • changedInput schema / properties / filters / items / properties / operator / description
      Previous value: -"A plain filter's operator: equals, contains, starts_with, matches (a whole-value pattern where * stands for any text, e.g. *://t.co/* on referrer; a pattern of only * is refused, use exists) or exists (trait and automated: equals only), case-sensitive except on query.utm_source, query.utm_medium and query.ref."New value: +"A plain filter's operator: equals, contains, starts_with, matches (a whole-value pattern where * stands for any text, e.g. *://t.co/* on referrer; a pattern of only * is refused, use exists) or exists (trait and automated: equals only), case-sensitive except on query.utm_source, query.utm_medium and query.ref. scroll_depth and time_on_page_seconds take equals, greater_than, less_than (both strict, > and <: scroll_depth greater_than 74 is 75 or more) or exists (has a value), with a whole number in range as the value, digits only. attrs.KEY also takes greater_than and less_than (strict), comparing the detail as a number: attrs.order_value greater_than 100, with a plain decimal number as the value (100, 34.5, -3; no exponent or separators); an event without the detail or whose detail is not a number matches neither. greater_than and less_than work on nothing else."
    • changedInput schema / properties / filters / items / properties / property / description
      Previous value: -"A plain filter's property: a standard property (page_origin, page_path, page_fragment, referrer, data_track, element_tag, element_selector, element_selector_generalized, element_text), attrs.KEY, query.PARAM, trait, or automated (true for automated visits: headless or program-driven browsers and AI agents browsing for a person; equals 'true' or 'false' only, e.g. automated equals false to count people only). Leave out in an any group."New value: +"A plain filter's property: a standard property (page_origin, page_path, page_fragment, referrer, data_track, element_tag, element_selector, element_selector_generalized, element_text), attrs.KEY, query.PARAM, trait, automated (true for automated visits: headless or program-driven browsers and AI agents browsing for a person; equals 'true' or 'false' only, e.g. automated equals false to count people only), or a page view's numbers: scroll_depth (how far down the page the visitor got, whole percent 0-100: 0 never scrolled, 100 the bottom) and time_on_page_seconds (active seconds on the page, 0-1800), null where no value arrived (an older tracker, a lost send), which no comparison matches. Leave out in an any group."
    • changedInput schema / properties / filters / items / properties / value / description
      Previous value: -"A plain filter's value (for matches, the pattern); required except for exists."New value: +"A plain filter's value (for matches, the pattern; for scroll_depth and time_on_page_seconds a whole number such as 75; for greater_than or less_than on attrs.KEY a plain decimal number such as 100 or 34.5); required except for exists."
    • changedInput schema / properties / measure / description
      Previous value: -"events (default): count the matching events. sum or average: add up or average the numeric event detail measure_property, per event, over the matching events whose value is a number. Values that are not numbers are left out and counted in non_numeric_events; an average bucket with no numbers is null, not 0."New value: +"events (default): count the matching events. sum or average: add up or average measure_property, per event, over the matching events whose value is a number: a numeric event detail, or a page view's scroll_depth (average only) or time_on_page_seconds. Values that are not numbers are left out and counted in non_numeric_events; an average bucket with no numbers is null, not 0."
    • changedInput schema / properties / measure_property / description
      Previous value: -"For sum and average only, and then required: the event detail to read, attrs.KEY (e.g. attrs.order_value for track('Purchase', { order_value: 34.5 })). list_property_keys lists the keys; filter to the event that carries it (e.g. data_track equals Purchase). A number is plain decimal text such as 34.5 or -2: '34,50', '€34' and '1e3' are not numbers."New value: +"For sum and average only, and then required: the event detail to read, attrs.KEY (e.g. attrs.order_value for track('Purchase', { order_value: 34.5 })), or scroll_depth (average only) or time_on_page_seconds: a page view's scroll depth in percent (0-100) and its active seconds (0-1800); only page views with a value take part (null means no value arrived, never 0), and a page_path filter narrows it to one page. list_property_keys lists the keys; filter to the event that carries a detail (e.g. data_track equals Purchase). A number is plain decimal text such as 34.5 or -2: '34,50', '€34' and '1e3' are not numbers."
    • changedInput schema / properties / series / items / properties / filters / items / properties / operator / description
      Previous value: -"A plain filter's operator: equals, contains, starts_with, matches (a whole-value pattern where * stands for any text, e.g. *://t.co/* on referrer; a pattern of only * is refused, use exists) or exists (trait and automated: equals only), case-sensitive except on query.utm_source, query.utm_medium and query.ref."New value: +"A plain filter's operator: equals, contains, starts_with, matches (a whole-value pattern where * stands for any text, e.g. *://t.co/* on referrer; a pattern of only * is refused, use exists) or exists (trait and automated: equals only), case-sensitive except on query.utm_source, query.utm_medium and query.ref. scroll_depth and time_on_page_seconds take equals, greater_than, less_than (both strict, > and <: scroll_depth greater_than 74 is 75 or more) or exists (has a value), with a whole number in range as the value, digits only. attrs.KEY also takes greater_than and less_than (strict), comparing the detail as a number: attrs.order_value greater_than 100, with a plain decimal number as the value (100, 34.5, -3; no exponent or separators); an event without the detail or whose detail is not a number matches neither. greater_than and less_than work on nothing else."
    • changedInput schema / properties / series / items / properties / filters / items / properties / property / description
      Previous value: -"A plain filter's property: a standard property (page_origin, page_path, page_fragment, referrer, data_track, element_tag, element_selector, element_selector_generalized, element_text), attrs.KEY, query.PARAM, trait, or automated (true for automated visits: headless or program-driven browsers and AI agents browsing for a person; equals 'true' or 'false' only, e.g. automated equals false to count people only). Leave out in an any group."New value: +"A plain filter's property: a standard property (page_origin, page_path, page_fragment, referrer, data_track, element_tag, element_selector, element_selector_generalized, element_text), attrs.KEY, query.PARAM, trait, automated (true for automated visits: headless or program-driven browsers and AI agents browsing for a person; equals 'true' or 'false' only, e.g. automated equals false to count people only), or a page view's numbers: scroll_depth (how far down the page the visitor got, whole percent 0-100: 0 never scrolled, 100 the bottom) and time_on_page_seconds (active seconds on the page, 0-1800), null where no value arrived (an older tracker, a lost send), which no comparison matches. Leave out in an any group."
    • changedInput schema / properties / series / items / properties / filters / items / properties / value / description
      Previous value: -"A plain filter's value (for matches, the pattern); required except for exists."New value: +"A plain filter's value (for matches, the pattern; for scroll_depth and time_on_page_seconds a whole number such as 75; for greater_than or less_than on attrs.KEY a plain decimal number such as 100 or 34.5); required except for exists."
    • changedInput schema / properties / series / items / properties / measure_property / description
      Previous value: -"For sum and average only, and then required: the event detail, attrs.KEY."New value: +"For sum and average only, and then required: the event detail, attrs.KEY, or scroll_depth (average only) or time_on_page_seconds, as the query's measure_property."
  2. First observed

TDQS

A4.1/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent, yet the description adds substantial behavioral context the annotations cannot: partial buckets and their covers_from/covers_to, the current hour reading incomplete and later hours reading 0, starts_before_data meaning zeros rather than quiet, non-numeric values skipped and surfaced via left_out/non_numeric_events, and summary_total being null when series are used. This is exactly the interpretive context an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is front-loaded with the capability and then the caveats, and at roughly 150 words for a 15-parameter tool it is appropriately sized. The semicolon-chained single paragraph is dense and harder to scan than bulleted caveats would be, but nearly every clause carries operational value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and 15 parameters, the description carries the full disclosure burden, and it does: it explains the key result fields (summary_total, result.series, result.table, comparison, left_out, covers_from/covers_to, data_from) and the timezone/date conventions. An agent can call this and interpret the response without guessing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description still adds cross-parameter meaning beyond any single schema field, such as breakdown returning only the top 10 with table raising the limit to 100, sort_by defaulting to A, and compare_previous returning change in comparison. Those interactions are useful even though many details are restated from the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a precise verb and resource: count events or sum/average a numeric detail, bucketed by day/week/month/hour, filtered, with breakdown or 1-4 series. Scope is clear enough that an agent knows this is the raw event-query tool. It never names a sibling (get_overview, get_feature_timeseries) to distinguish itself, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied through constraints (series cannot combine with breakdown, compare_previous takes no breakdown, hour requires a range of at most 31 days, omit from/to for the last 28 complete days). There is no explicit statement of when to choose this over get_overview or get_funnel_trend, which is the main gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources