Skip to main content
Glama

ga4_compare_periods

Compare two date ranges side by side to get each metric's current and previous values plus relative change for week-over-week or month-over-month reporting.

Instructions

Compare two date ranges side by side: each row gets the metric in the current period, the previous period, and the relative change. Good for week over week or month over month. Requires: Google Analytics Data API (analyticsdata.googleapis.com) enabled on the quota project; Lector (Viewer) en la propiedad de GA4. If it fails for access, the error explains how to fix it; ga4_check_access checks everything at once.

Input Schema

NameRequiredDescriptionDefault
limitNo
metricsYesMetric API names
propertyNoSaved property name (see ga4_list_properties). Defaults to the default property.
dimensionsNoDimension API names to group by
current_endYesCurrent period end
previous_endYesPrevious period end
current_startYesCurrent period start, YYYY-MM-DD or relative
metric_filterNoData API FilterExpression for metrics, e.g. {"filter":{"fieldName":"totalUsers","numericFilter":{"operation":"GREATER_THAN","value":{"int64Value":"100"}}}}
previous_startYesPrevious period start
dimension_filterNoData API FilterExpression for dimensions, e.g. {"filter":{"fieldName":"eventName","stringFilter":{"matchType":"BEGINS_WITH","value":"Checkout_"}}}

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.0

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description usefully discloses the required API enablement, GA4 Viewer permission, row-level comparison behavior, and access-error guidance. It does not cover operational details such as sampling, sorting, or how relative change handles a zero previous-period value.

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

Conciseness5/5

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

The core operation and output are front-loaded, followed by concise use cases, prerequisites, and troubleshooting guidance. Each sentence serves a distinct purpose, although the brief language switch in the permission requirement is slightly inconsistent.

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

Completeness4/5

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

Together with the rich input schema, the description provides enough information to select and invoke this comparatively complex tool, including its output concept and access prerequisites. Because there is no output schema, details such as result structure, row ordering, and the relative-change calculation would make it more complete.

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 already high, but the description adds meaning by explaining how the four date parameters form current and previous periods and how the selected metrics appear in the comparison. It does not add date-syntax guidance for the parameters whose schema descriptions omit it.

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

Purpose5/5

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

The description clearly states that the tool compares GA4 metrics across two date ranges and returns current-period, previous-period, and relative-change values for each row. This comparative output distinguishes it from ordinary reporting siblings such as ga4_run_report.

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

Usage Guidelines4/5

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

It gives concrete use cases—week-over-week and month-over-month analysis—and directs agents to ga4_check_access for comprehensive access diagnosis. It does not explicitly say when a standard report or another GA4 sibling would be preferable.

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