試用 Google Analytics 的 MCP 伺服器。從
GitHub 安裝,詳情請參閱
公告。
Metric
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
報表的量化測量資料。舉例來說,eventCount
指標是事件總數。最多可有 10 個指標。
JSON 表示法 |
{
"name": string,
"expression": string,
"invisible": boolean
} |
欄位 |
name |
string
指標的名稱。請參閱 API 指標,瞭解 runReport 和 batchRunReports 等核心報表方法支援的指標名稱清單。如需 runRealtimeReport 方法支援的指標名稱清單,請參閱「即時指標」。如需 runFunnelReport 方法支援的指標名稱清單,請參閱漏斗指標。 如果指定 expression ,name 可以是您要在允許的字元集內的任何字串。舉例來說,如果 expression 是 screenPageViews/sessions ,您可以將該指標的名稱命名為 = viewsPerSession 。您選擇的指標名稱必須符合規則運算式 ^[a-zA-Z0-9_]$ 。 指標是由 metricFilter 、orderBys 和 expression 指標中的 name 參照。
|
expression |
string
衍生指標的數學運算式。舉例來說,每位使用者的「事件計數」指標是 eventCount/totalUsers 。
|
invisible |
boolean
指出報表回應中是否未顯示指標。如果指標不可見,該指標不會在回應中產生資料欄,但可用於 metricFilter 、orderBys 或指標 expression 。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間: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`. |"]]