Skip to main content
Glama
dienhokhanh

ga4-mcp-server

by dienhokhanh

Run GA4 pivot report

run_pivot_report
Read-only

Cross-tabulate Google Analytics 4 metrics by dimensions in up to three pivots with filters and date ranges to compare segment performance.

Instructions

Run a pivot (cross-tab) report. Every dimension must appear in exactly one pivot's fieldNames. Example: pivots [{fieldNames:["country"],limit:5},{fieldNames:["deviceCategory"],limit:3}] with metric sessions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pivotsYes
metricsYesMetric API names, e.g. ["activeUsers","sessions","keyEvents","totalRevenue"].
propertyNoGA4 property: numeric ID ("123456789"), resource name ("properties/123456789") or display name ("My Website"). Defaults to GA4_DEFAULT_PROPERTY if set.
dateRangesNoUp to 4 date ranges. Defaults to the last 28 days (28daysAgo → yesterday).
dimensionsYes
currencyCodeNoISO 4217 code, e.g. "USD". Defaults to the property currency.
metricFilterNoA GA4 Data API FilterExpression object. Examples: {"filter":{"fieldName":"country","stringFilter":{"matchType":"EXACT","value":"United States"}}} {"filter":{"fieldName":"eventName","inListFilter":{"values":["purchase","sign_up"]}}} {"filter":{"fieldName":"sessions","numericFilter":{"operation":"GREATER_THAN","value":{"int64Value":"100"}}}} {"andGroup":{"expressions":[<expr>,<expr>]}} · {"orGroup":{"expressions":[...]}} · {"notExpression":<expr>} stringFilter.matchType: EXACT | BEGINS_WITH | ENDS_WITH | CONTAINS | FULL_REGEXP | PARTIAL_REGEXP. Use dimension fields in dimensionFilter and metric fields in metricFilter.
keepEmptyRowsNo
dimensionFilterNoA GA4 Data API FilterExpression object. Examples: {"filter":{"fieldName":"country","stringFilter":{"matchType":"EXACT","value":"United States"}}} {"filter":{"fieldName":"eventName","inListFilter":{"values":["purchase","sign_up"]}}} {"filter":{"fieldName":"sessions","numericFilter":{"operation":"GREATER_THAN","value":{"int64Value":"100"}}}} {"andGroup":{"expressions":[<expr>,<expr>]}} · {"orGroup":{"expressions":[...]}} · {"notExpression":<expr>} stringFilter.matchType: EXACT | BEGINS_WITH | ENDS_WITH | CONTAINS | FULL_REGEXP | PARTIAL_REGEXP. Use dimension fields in dimensionFilter and metric fields in metricFilter.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and openWorldHint=true, so the safety profile is covered. The description adds one genuine behavioral rule not present in the schema (each dimension must belong to exactly one pivot), but says nothing about the 3-pivot maximum, error behavior, or that the call hits the live GA4 API.

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?

Three short sentences, front-loaded with the purpose and immediately followed by the key constraint and a worked example. No filler, though the example crowds out room for the missing routing guidance.

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

Completeness3/5

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

For a 9-parameter tool with nested objects and no output schema, the description covers only the pivots surface. Filtering, property resolution, date-range defaults and return shape are left entirely to the schema, which is adequate but thin for this complexity.

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

Parameters3/5

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

Schema coverage is 67%, and the description does add a non-schema rule about pivot fieldNames plus a concrete example with limits. It does not compensate for the uncovered parameters (property, currencyCode, keepEmptyRows, most of the nested pivot object), leaving the baseline level.

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?

States a specific verb and resource pair ('Run a pivot (cross-tab) report'), which is precise enough to distinguish it conceptually from run_report. However, it never explicitly names run_report as the alternative, so the differentiation is left to inference.

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

Usage Guidelines2/5

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

There is no guidance on when to choose this over run_report or batch_run_reports, which are the obvious siblings for reporting. The constraint 'Every dimension must appear in exactly one pivot's fieldNames' is a validation rule for the pivots parameter rather than routing guidance.

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