试用 Google Analytics 的 MCP 服务器。从
GitHub 安装,并参阅
公告了解详情。
Metric
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
报告的量化衡量标准。例如,eventCount
指标表示事件总数。最多允许请求 10 个指标。
JSON 表示法 |
{
"name": string,
"expression": string,
"invisible": boolean
} |
字段 |
name |
string
指标的名称。有关核心报告方法(例如 runReport 和 batchRunReports )支持的指标名称的列表,请参阅 API 指标。如需查看 runRealtimeReport 方法支持的指标名称列表,请参阅实时指标。如需查看 runFunnelReport 方法支持的指标名称列表,请参阅漏斗指标。 如果指定了 expression ,则 name 可以是允许的字符集内的您想要的任何字符串。例如,如果 expression 为 screenPageViews/sessions ,则您可以将该指标的名称命名为 viewsPerSession 。您选择的指标名称必须与正则表达式 ^[a-zA-Z0-9_]$ 匹配。 name 在 metricFilter 、orderBys 和指标 expression 中引用了指标。
|
expression |
string
派生指标的数学表达式。例如,“每位用户的事件数”指标为 eventCount/totalUsers 。
|
invisible |
boolean
指明某个指标是否在报告响应中不可见。如果某个指标不可见,则它不会在响应中生成列,但可以在 metricFilter 、orderBys 或指标 expression 中使用。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eMetrics quantify report data, such as the total events with \u003ccode\u003eeventCount\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can request up to 10 metrics in a report.\u003c/p\u003e\n"],["\u003cp\u003eMetrics are defined by \u003ccode\u003ename\u003c/code\u003e, \u003ccode\u003eexpression\u003c/code\u003e for calculations, and \u003ccode\u003einvisible\u003c/code\u003e to control visibility.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ename\u003c/code\u003e can be a standard metric or a custom name when \u003ccode\u003eexpression\u003c/code\u003e is used.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eexpression\u003c/code\u003e enables creating calculated metrics like "Event count per user" (\u003ccode\u003eeventCount/totalUsers\u003c/code\u003e).\u003c/p\u003e\n"]]],["This document outlines the structure for defining quantitative measurements (metrics) within a report. Each metric has a `name` (a string that can be custom when using an `expression`), an optional `expression` (a mathematical formula to derive the metric), and an `invisible` boolean, the metric can be excluded from the report's output but used for filtering, ordering, or in other metrics' `expression` . Up to 10 metrics are allowed per request.\n"],null,["# Metric\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nThe quantitative measurements of a report. For example, the metric `eventCount` is the total number of events. Requests are allowed up to 10 metrics.\n\n| JSON representation |\n|------------------------------------------------------------------------|\n| ``` { \"name\": string, \"expression\": string, \"invisible\": boolean } ``` |\n\n| Fields ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` The name of the metric. See the [API Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#metrics) for the list of metric names supported by core reporting methods such as `runReport` and `batchRunReports`. See [Realtime Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema#metrics) for the list of metric names supported by the `runRealtimeReport` method. See [Funnel Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/exploration-api-schema#metrics) for the list of metric names supported by the `runFunnelReport` method. If `expression` is specified, `name` can be any string that you would like within the allowed character set. For example if `expression` is `screenPageViews/sessions`, you could call that metric's name = `viewsPerSession`. Metric names that you choose must match the regular expression `^[a-zA-Z0-9_]$`. Metrics are referenced by `name` in `metricFilter`, `orderBys`, and metric `expression`. |\n| `expression` | `string` A mathematical expression for derived metrics. For example, the metric Event count per user is `eventCount/totalUsers`. |\n| `invisible` | `boolean` 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 `metricFilter`, `orderBys`, or a metric `expression`. |"]]