Tool: run_report
Returns a customized report of your Google Analytics event data.
The following sample demonstrate how to use curl to invoke the run_report MCP tool.
| Curl Request |
|---|
curl --location 'https://analyticsdata.googleapis.com/mcp/v1' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "run_report", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
The request to generate a report.
RunReportRequest
| JSON representation |
|---|
{ "property": string, "dimensions": [ { object ( |
| Fields | |
|---|---|
property |
A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see where to find your Property ID. Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234 |
dimensions[] |
The dimensions requested and displayed. |
metrics[] |
The metrics requested and displayed. |
dateRanges[] |
Date ranges of data to read. If multiple date ranges are requested, each response row will contain a zero based date range index. If two date ranges overlap, the event data for the overlapping days is included in the response rows for both date ranges. In a cohort request, this |
dimensionFilter |
Dimension filters let you ask for only specific dimension values in the report. To learn more, see Fundamentals of Dimension Filters for examples. Metrics cannot be used in this filter. |
metricFilter |
The filter clause of metrics. Applied after aggregating the report's rows, similar to SQL having-clause. Dimensions cannot be used in this filter. |
offset |
The row count of the start row. The first row is counted as row 0. When paging, the first request does not specify offset; or equivalently, sets offset to 0; the first request returns the first To learn more about this pagination parameter, see Pagination. |
limit |
The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,000 rows per request, no matter how many you ask for. The API can also return fewer rows than the requested To learn more about this pagination parameter, see Pagination. |
metricAggregations[] |
Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)". Aggregates including both comparisons and multiple date ranges will be aggregated based on the date ranges. |
orderBys[] |
Specifies how rows are ordered in the response. Requests including both comparisons and multiple date ranges will have order bys applied on the comparisons. |
currencyCode |
A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the property's default currency. |
cohortSpec |
Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present. |
keepEmptyRows |
If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. Regardless of this For example if a property never logs a |
returnPropertyQuota |
Toggles whether to return the current state of this Google Analytics property's quota. Quota is returned in PropertyQuota. |
comparisons[] |
Optional. The configuration of comparisons requested and displayed. The request only requires a comparisons field in order to receive a comparison column in the response. |
Dimension
| JSON representation |
|---|
{
"name": string,
"dimensionExpression": {
object ( |
| Fields | |
|---|---|
name |
The name of the dimension. See the API Dimensions for the list of dimension names supported by core reporting methods such as If Dimensions are referenced by |
dimensionExpression |
One dimension can be the result of an expression of multiple dimensions. For example, dimension "country, city": concatenate(country, ", ", city). |
DimensionExpression
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field one_expression. Specify one type of dimension expression for DimensionExpression. one_expression can be only one of the following: |
|
lowerCase |
Used to convert a dimension value to lower case. |
upperCase |
Used to convert a dimension value to upper case. |
concatenate |
Used to combine dimension values to a single dimension. For example, dimension "country, city": concatenate(country, ", ", city). |
CaseExpression
| JSON representation |
|---|
{ "dimensionName": string } |
| Fields | |
|---|---|
dimensionName |
Name of a dimension. The name must refer back to a name in dimensions field of the request. |
ConcatenateExpression
| JSON representation |
|---|
{ "dimensionNames": [ string ], "delimiter": string } |
| Fields | |
|---|---|
dimensionNames[] |
Names of dimensions. The names must refer back to names in the dimensions field of the request. |
delimiter |
The delimiter placed between dimension names. Delimiters are often single characters such as "|" or "," but can be longer strings. If a dimension value contains the delimiter, both will be present in response with no distinction. For example if dimension 1 value = "US,FR", dimension 2 value = "JP", and delimiter = ",", then the response will contain "US,FR,JP". |
Metric
| JSON representation |
|---|
{ "name": string, "expression": string, "invisible": boolean } |
| Fields | |
|---|---|
name |
The name of the metric. See the API Metrics for the list of metric names supported by core reporting methods such as If Metrics are referenced by |
expression |
A mathematical expression for derived metrics. For example, the metric Event count per user is |
invisible |
Indicates if a metric is invisible in the report response. If a metric is invisible, the metric will not produce a column in the response, but can be used in |
DateRange
| JSON representation |
|---|
{ "startDate": string, "endDate": string, "name": string } |
| Fields | |
|---|---|
startDate |
The inclusive start date for the query in the format |
endDate |
The inclusive end date for the query in the format |
name |
Assigns a name to this date range. The dimension |
FilterExpression
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field expr. Specify one type of filter expression for FilterExpression. expr can be only one of the following: |
|
andGroup |
The FilterExpressions in and_group have an AND relationship. |
orGroup |
The FilterExpressions in or_group have an OR relationship. |
notExpression |
The FilterExpression is NOT of not_expression. |
filter |
A primitive filter. In the same FilterExpression, all of the filter's field names need to be either all dimensions or all metrics. |
FilterExpressionList
| JSON representation |
|---|
{
"expressions": [
{
object ( |
| Fields | |
|---|---|
expressions[] |
A list of filter expressions. |
Filter
| JSON representation |
|---|
{ "fieldName": string, // Union field |
| Fields | |
|---|---|
fieldName |
The dimension name or metric name. In most methods, dimensions & metrics can be used for the first time in this field. However in a RunPivotReportRequest, this field must be additionally specified by name in the RunPivotReportRequest's dimensions or metrics. |
Union field one_filter. Specify one type of filter for Filter. one_filter can be only one of the following: |
|
stringFilter |
Strings related filter. |
inListFilter |
A filter for in list values. |
numericFilter |
A filter for numeric or date values. |
betweenFilter |
A filter for two values. |
emptyFilter |
A filter for empty values such as "(not set)" and "" values. |
StringFilter
| JSON representation |
|---|
{
"matchType": enum ( |
| Fields | |
|---|---|
matchType |
The match type for this filter. |
value |
The string value used for the matching. |
caseSensitive |
If true, the string value is case sensitive. |
InListFilter
| JSON representation |
|---|
{ "values": [ string ], "caseSensitive": boolean } |
| Fields | |
|---|---|
values[] |
The list of string values. Must be non-empty. |
caseSensitive |
If true, the string value is case sensitive. |
NumericFilter
| JSON representation |
|---|
{ "operation": enum ( |
| Fields | |
|---|---|
operation |
The operation type for this filter. |
value |
A numeric value or a date value. |
NumericValue
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field one_value. One of a numeric value one_value can be only one of the following: |
|
int64Value |
Integer value |
doubleValue |
Double value |
BetweenFilter
| JSON representation |
|---|
{ "fromValue": { object ( |
| Fields | |
|---|---|
fromValue |
Begins with this number. |
toValue |
Ends with this number. |
OrderBy
| JSON representation |
|---|
{ "desc": boolean, // Union field |
| Fields | |
|---|---|
desc |
If true, sorts by descending order. |
Union field one_order_by. Specify one type of order by for OrderBy. one_order_by can be only one of the following: |
|
metric |
Sorts results by a metric's values. |
dimension |
Sorts results by a dimension's values. |
pivot |
Sorts results by a metric's values within a pivot column group. |
MetricOrderBy
| JSON representation |
|---|
{ "metricName": string } |
| Fields | |
|---|---|
metricName |
A metric name in the request to order by. |
DimensionOrderBy
| JSON representation |
|---|
{
"dimensionName": string,
"orderType": enum ( |
| Fields | |
|---|---|
dimensionName |
A dimension name in the request to order by. |
orderType |
Controls the rule for dimension value ordering. |
PivotOrderBy
| JSON representation |
|---|
{
"metricName": string,
"pivotSelections": [
{
object ( |
| Fields | |
|---|---|
metricName |
In the response to order by, order rows by this column. Must be a metric name from the request. |
pivotSelections[] |
Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair. |
PivotSelection
| JSON representation |
|---|
{ "dimensionName": string, "dimensionValue": string } |
| Fields | |
|---|---|
dimensionName |
Must be a dimension name from the request. |
dimensionValue |
Order by only when the named dimension is this value. |
CohortSpec
| JSON representation |
|---|
{ "cohorts": [ { object ( |
| Fields | |
|---|---|
cohorts[] |
Defines the selection criteria to group users into cohorts. Most cohort reports define only a single cohort. If multiple cohorts are specified, each cohort can be recognized in the report by their name. |
cohortsRange |
Cohort reports follow cohorts over an extended reporting date range. This range specifies an offset duration to follow the cohorts over. |
cohortReportSettings |
Optional settings for a cohort report. |
Cohort
| JSON representation |
|---|
{
"name": string,
"dimension": string,
"dateRange": {
object ( |
| Fields | |
|---|---|
name |
Assigns a name to this cohort. The dimension |
dimension |
Dimension used by the cohort. Required and only supports |
dateRange |
The cohort selects users whose first touch date is between start date and end date defined in the In a cohort request, this This |
CohortsRange
| JSON representation |
|---|
{
"granularity": enum ( |
| Fields | |
|---|---|
granularity |
Required. The granularity used to interpret the |
startOffset |
If If If |
endOffset |
Required. If If If |
CohortReportSettings
| JSON representation |
|---|
{ "accumulate": boolean } |
| Fields | |
|---|---|
accumulate |
If true, accumulates the result from first touch day to the end day. Not supported in |
Comparison
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
name |
Each comparison produces separate rows in the response. In the response, this comparison is identified by this name. If name is unspecified, we will use the saved comparisons display name. |
Union field one_comparison. One kind of comparison value one_comparison can be only one of the following: |
|
dimensionFilter |
A basic comparison. |
comparison |
A saved comparison identified by the comparison's resource name. For example, 'comparisons/1234'. |
MatchType
The match type of a string filter
| Enums | |
|---|---|
MATCH_TYPE_UNSPECIFIED |
Unspecified |
EXACT |
Exact match of the string value. |
BEGINS_WITH |
Begins with the string value. |
ENDS_WITH |
Ends with the string value. |
CONTAINS |
Contains the string value. |
FULL_REGEXP |
Full match for the regular expression with the string value. |
PARTIAL_REGEXP |
Partial match for the regular expression with the string value. |
Operation
The operation applied to a numeric filter
| Enums | |
|---|---|
OPERATION_UNSPECIFIED |
Unspecified. |
EQUAL |
Equal |
LESS_THAN |
Less than |
LESS_THAN_OR_EQUAL |
Less than or equal |
GREATER_THAN |
Greater than |
GREATER_THAN_OR_EQUAL |
Greater than or equal |
MetricAggregation
Represents aggregation of metrics.
| Enums | |
|---|---|
METRIC_AGGREGATION_UNSPECIFIED |
Unspecified operator. |
TOTAL |
SUM operator. |
MINIMUM |
Minimum operator. |
MAXIMUM |
Maximum operator. |
COUNT |
Count operator. |
OrderType
Rule to order the string dimension values by.
| Enums | |
|---|---|
ORDER_TYPE_UNSPECIFIED |
Unspecified. |
ALPHANUMERIC |
Alphanumeric sort by Unicode code point. For example, "2" < "A" < "X" < "b" < "z". |
CASE_INSENSITIVE_ALPHANUMERIC |
Case insensitive alphanumeric sort by lower case Unicode code point. For example, "2" < "A" < "b" < "X" < "z". |
NUMERIC |
Dimension values are converted to numbers before sorting. For example in NUMERIC sort, "25" < "100", and in ALPHANUMERIC sort, "100" < "25". Non-numeric dimension values all have equal ordering value below all numeric values. |
Granularity
The granularity used to interpret the startOffset and endOffset for the extended reporting date range for a cohort report.
| Enums | |
|---|---|
GRANULARITY_UNSPECIFIED |
Should never be specified. |
DAILY |
Daily granularity. Commonly used if the cohort's dateRange is a single day and the request contains cohortNthDay. |
WEEKLY |
Weekly granularity. Commonly used if the cohort's dateRange is a week in duration (starting on Sunday and ending on Saturday) and the request contains cohortNthWeek. |
MONTHLY |
Monthly granularity. Commonly used if the cohort's dateRange is a month in duration and the request contains cohortNthMonth. |
Output Schema
The response report table corresponding to a request.
RunReportResponse
| JSON representation |
|---|
{ "dimensionHeaders": [ { object ( |
| Fields | |
|---|---|
dimensionHeaders[] |
Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows. |
metricHeaders[] |
Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows. |
rows[] |
Rows of dimension value combinations and metric values in the report. |
totals[] |
If requested, the totaled values of metrics. |
maximums[] |
If requested, the maximum values of metrics. |
minimums[] |
If requested, the minimum values of metrics. |
rowCount |
The total number of rows in the query result. To learn more about this pagination parameter, see Pagination. |
metadata |
Metadata for the report. |
propertyQuota |
This Google Analytics property's quota state including this request. |
kind |
Identifies what kind of resource this message is. This |
DimensionHeader
| JSON representation |
|---|
{ "name": string } |
| Fields | |
|---|---|
name |
The dimension's name. |
MetricHeader
| JSON representation |
|---|
{
"name": string,
"type": enum ( |
| Fields | |
|---|---|
name |
The metric's name. |
type |
The metric's data type. |
Row
| JSON representation |
|---|
{ "dimensionValues": [ { object ( |
| Fields | |
|---|---|
dimensionValues[] |
List of requested dimension values. In a PivotReport, dimension_values are only listed for dimensions included in a pivot. |
metricValues[] |
List of requested visible metric values. |
DimensionValue
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field one_value. One kind of dimension value one_value can be only one of the following: |
|
value |
Value as a string if the dimension type is a string. |
MetricValue
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
value |
Measurement value. See MetricHeader for type. |
ResponseMetaData
| JSON representation |
|---|
{ "dataLossFromOtherRow": boolean, "samplingMetadatas": [ { object ( |
| Fields | |
|---|---|
dataLossFromOtherRow |
If true, indicates some buckets of dimension combinations are rolled into "(other)" row. This can happen for high cardinality reports. The metadata parameter dataLossFromOtherRow is populated based on the aggregated data table used in the report. The parameter will be accurately populated regardless of the filters and limits in the report. For example, the (other) row could be dropped from the report because the request contains a filter on sessionSource = google. This parameter will still be populated if data loss from other row was present in the input aggregate data used to generate this report. To learn more, see About the (other) row and data sampling. |
samplingMetadatas[] |
If this report results is sampled, this describes the percentage of events used in this report. One However if the results are not sampled, this field will not be defined. |
Union field
|
|
schemaRestrictionResponse |
Describes the schema restrictions actively enforced in creating this report. To learn more, see Access and data-restriction management. |
Union field
|
|
currencyCode |
The currency code used in this report. Intended to be used in formatting currency metrics like Currency codes are string encodings of currency types from the ISO 4217 standard (https://en.wikipedia.org/wiki/ISO_4217); for example "USD", "EUR", "JPY". To learn more, see https://support.google.com/analytics/answer/9796179. |
Union field
|
|
timeZone |
The property's current timezone. Intended to be used to interpret time-based dimensions like |
Union field
|
|
emptyReason |
If empty reason is specified, the report is empty for this reason. |
Union field
|
|
subjectToThresholding |
If |
SchemaRestrictionResponse
| JSON representation |
|---|
{
"activeMetricRestrictions": [
{
object ( |
| Fields | |
|---|---|
activeMetricRestrictions[] |
All restrictions actively enforced in creating the report. For example, |
ActiveMetricRestriction
| JSON representation |
|---|
{ "restrictedMetricTypes": [ enum ( |
| Fields | |
|---|---|
restrictedMetricTypes[] |
The reason for this metric's restriction. |
Union field
|
|
metricName |
The name of the restricted metric. |
SamplingMetadata
| JSON representation |
|---|
{ "samplesReadCount": string, "samplingSpaceSize": string } |
| Fields | |
|---|---|
samplesReadCount |
The total number of events read in this sampled report for a date range. This is the size of the subset this property's data that was analyzed in this report. |
samplingSpaceSize |
The total number of events present in this property's data that could have been analyzed in this report for a date range. Sampling uncovers the meaningful information about the larger data set, and this is the size of the larger data set. To calculate the percentage of available data that was used in this report, compute |
PropertyQuota
| JSON representation |
|---|
{ "tokensPerDay": { object ( |
| Fields | |
|---|---|
tokensPerDay |
Standard Analytics Properties can use up to 200,000 tokens per day; Analytics 360 Properties can use 2,000,000 tokens per day. Most requests consume fewer than 10 tokens. |
tokensPerHour |
Standard Analytics Properties can use up to 40,000 tokens per hour; Analytics 360 Properties can use 400,000 tokens per hour. An API request consumes a single number of tokens, and that number is deducted from all of the hourly, daily, and per project hourly quotas. |
concurrentRequests |
Standard Analytics Properties can send up to 10 concurrent requests; Analytics 360 Properties can use up to 50 concurrent requests. |
serverErrorsPerProjectPerHour |
Standard Analytics Properties and cloud project pairs can have up to 10 server errors per hour; Analytics 360 Properties and cloud project pairs can have up to 50 server errors per hour. |
potentiallyThresholdedRequestsPerHour |
Analytics Properties can send up to 120 requests with potentially thresholded dimensions per hour. In a batch request, each report request is individually counted for this quota if the request contains potentially thresholded dimensions. |
tokensPerProjectPerHour |
Analytics Properties can use up to 35% of their tokens per project per hour. This amounts to standard Analytics Properties can use up to 14,000 tokens per project per hour, and Analytics 360 Properties can use 140,000 tokens per project per hour. An API request consumes a single number of tokens, and that number is deducted from all of the hourly, daily, and per project hourly quotas. |
QuotaStatus
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
consumed |
Quota consumed by this request. |
Union field
|
|
remaining |
Quota remaining after this request. |
MetricType
A metric's value type.
| Enums | |
|---|---|
METRIC_TYPE_UNSPECIFIED |
Unspecified type. |
TYPE_INTEGER |
Integer type. |
TYPE_FLOAT |
Floating point type. |
TYPE_SECONDS |
A duration of seconds; a special floating point type. |
TYPE_MILLISECONDS |
A duration in milliseconds; a special floating point type. |
TYPE_MINUTES |
A duration in minutes; a special floating point type. |
TYPE_HOURS |
A duration in hours; a special floating point type. |
TYPE_STANDARD |
A custom metric of standard type; a special floating point type. |
TYPE_CURRENCY |
An amount of money; a special floating point type. |
TYPE_FEET |
A length in feet; a special floating point type. |
TYPE_MILES |
A length in miles; a special floating point type. |
TYPE_METERS |
A length in meters; a special floating point type. |
TYPE_KILOMETERS |
A length in kilometers; a special floating point type. |
RestrictedMetricType
Categories of data that you may be restricted from viewing on certain Google Analytics properties.
| Enums | |
|---|---|
RESTRICTED_METRIC_TYPE_UNSPECIFIED |
Unspecified type. |
COST_DATA |
Cost metrics such as adCost. |
REVENUE_DATA |
Revenue metrics such as purchaseRevenue. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ✅