实时维度和指标
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Analytics Data API 的 Realtime 方法支持在查询中使用的维度和指标。核心报告方法(例如 RunReport
)接受的维度和指标与实时方法不同。
维度
您可以在任何媒体资源的报告中请求以下维度。在 Dimension
资源的 name
字段中,为报告响应中的维度列指定“API 名称”。
API 名称 |
界面名称 |
说明 |
appVersion |
应用版本 |
应用的 versionName (Android) 或简短的软件包版本 (iOS)。 |
audienceId |
受众群体 ID |
受众群体的数字标识符。在报告的日期范围内,用户按其所属的受众群体进行报告。当前的用户行为不会影响报告中的既往受众群体成员资格。 |
audienceName |
受众群体名称 |
受众群体的指定名称。在报告的日期范围内,用户按其所属的受众群体进行报告。当前的用户行为不会影响报告中的既往受众群体成员资格。 |
audienceResourceName |
受众群体资源名称 |
相应受众群体的资源名称。资源名称包含集合标识符和资源标识符,用于唯一标识资源;如需了解详情,请参阅资源名称。 |
city |
城市 |
发起用户活动的城市。 |
cityId |
城市 ID |
用户发起活动时所处城市的地理位置 ID,根据用户的 IP 地址得出。 |
country |
国家/地区 |
发起用户活动的国家/地区。 |
countryId |
国家/地区 ID |
用户发起活动时所处的国家/地区的地理位置 ID,根据用户的 IP 地址得出。根据 ISO 3166-1 alpha-2 标准设置格式。 |
deviceCategory |
设备类别 |
设备类型:桌面设备、平板电脑或移动设备。 |
eventName |
事件名称 |
事件名称。 |
minutesAgo |
实时(若干分钟前) |
相应事件的收集时间距离现在的时间(以分钟为单位)。00 表示当前分钟,01 表示上一分钟。 |
platform |
平台 |
指您的应用或网站在哪个平台上运行;例如 Web、iOS 或 Android。如需确定报告中的视频流类型,请同时使用平台和 streamId。 |
streamId |
数据流 ID |
应用或网站的数字数据流标识符。 |
streamName |
数据流名称 |
应用或网站的数据流名称。 |
unifiedScreenName |
网页标题和屏幕名称 |
记录事件的网页标题(网站)或屏幕名称(应用)。 |
自定义维度
Realtime Data API 可以根据用户级范围的自定义维度创建报告。如需详细了解自定义维度,请参阅自定义用户属性。自定义维度通过维度参数名称和范围在 API 报告请求中指定。例如,在 Data API 请求中包含 "customUser:last_level"
,以针对参数名称为 "last_level"
的用户级范围自定义维度创建报告。如果相应媒体资源尚未注册此用户级自定义维度,此 API 请求将失败。
以下是自定义维度的一般语法。您可以查询 Metadata API 方法,以列出媒体资源的所有自定义维度。
通用 API 名称 |
说明 |
customUser:parameter_name |
parameter_name 的用户级范围的自定义维度。 |
实时 API 不支持事件级范围的自定义维度。
指标
您可以在任何媒体资源的报告中请求以下指标。在 Metric
资源的 name
字段中指定报告响应中指标列的“API 名称”。
API 名称 |
界面名称 |
说明 |
activeUsers |
活跃用户数 |
访问过您的网站或应用的去重用户数。 |
eventCount |
事件数 |
事件数量。 |
keyEvents |
关键事件 |
关键事件数。将事件标记为关键事件会从创建之时起影响报告,但不会更改历史数据。您可以在 Google Analytics 中将任何事件标记为关键事件,有些事件(例如 first_open 或 purchase )默认情况下会被标记为关键事件。 |
screenPageViews |
观看次数 |
用户浏览的应用界面或网页的数量。对同一网页或屏幕的重复浏览也会计入。(screen_view 事件数 + page_view 事件数)。 |
实时 API 不支持事件级范围的自定义指标。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
[null,null,["最后更新时间 (UTC):2025-07-29。"],[[["\u003cp\u003eThe Realtime reporting method of the Analytics Data API allows you to query specific dimensions and metrics to analyze real-time user behavior on your app or website.\u003c/p\u003e\n"],["\u003cp\u003eSupported dimensions include user demographics (like city and country), device information, app version, audience data, event details, and user-scoped custom dimensions.\u003c/p\u003e\n"],["\u003cp\u003eYou can use metrics like \u003ccode\u003eactiveUsers\u003c/code\u003e, \u003ccode\u003eeventCount\u003c/code\u003e, \u003ccode\u003escreenPageViews\u003c/code\u003e, and \u003ccode\u003ekeyEvents\u003c/code\u003e to understand real-time user engagement.\u003c/p\u003e\n"],["\u003cp\u003eUnlike Core Reporting methods, the Realtime method uses a different set of dimensions and metrics and doesn't support event-scoped custom dimensions or metrics.\u003c/p\u003e\n"]]],["The Realtime Analytics Data API supports specific dimensions and metrics for querying. Dimensions include `appVersion`, `audienceId/Name/ResourceName`, geographic data (`city/Id`, `country/Id`), `deviceCategory`, `eventName`, `minutesAgo`, `platform`, `streamId/Name`, and `unifiedScreenName`. User-scoped custom dimensions are supported using the `customUser:parameter_name` format. Supported metrics are `activeUsers`, `eventCount`, `keyEvents`, and `screenPageViews`. Event-scoped custom dimensions and metrics are not supported in the Realtime API.\n"],null,["# Realtime Dimensions & Metrics\n\nThe dimensions and metrics supported in queries to the [Realtime method](/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runRealtimeReport) of the Analytics Data API. The\nCore Reporting methods ([`RunReport`](/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport)\nfor example) accept a different set of [Dimensions \\& Metrics](/analytics/devguides/reporting/data/v1/api-schema)\nthan the Realtime method.\n\nDimensions\n----------\n\nThe following dimensions can be requested in reports for any property. Specify\nthe \"API Name\" in a [`Dimension`](/analytics/devguides/reporting/data/v1/rest/v1beta/Dimension) resource's `name`\nfield for a column of the dimension in the report response.\n\n| API Name | UI Name | Description |\n|------------------------|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `appVersion` | App version | The app's versionName (Android) or short bundle version (iOS). |\n| `audienceId` | Audience ID | The numeric identifier of an Audience. Users are reported in the audiences to which they belonged during the report's date range. Current user behavior does not affect historical audience membership in reports. |\n| `audienceName` | Audience name | The given name of an Audience. Users are reported in the audiences to which they belonged during the report's date range. Current user behavior does not affect historical audience membership in reports. |\n| `audienceResourceName` | Audience resource name | The resource name of this audience. Resource names contain both collection \\& resource identifiers to uniquely identify a resource; to learn more, see [Resource names](//google.aip.dev/122). |\n| `city` | City | The city from which the user activity originated. |\n| `cityId` | City ID | The geographic ID of the city from which the user activity originated, derived from their IP address. |\n| `country` | Country | The country from which the user activity originated. |\n| `countryId` | Country ID | The geographic ID of the country from which the user activity originated, derived from their IP address. Formatted according to ISO 3166-1 alpha-2 standard. |\n| `deviceCategory` | Device category | The type of device: Desktop, Tablet, or Mobile. |\n| `eventName` | Event name | The name of the event. |\n| `minutesAgo` | Realtime minutes ago | The number of minutes ago that an event was collected. 00 is the current minute, and 01 means the previous minute. |\n| `platform` | Platform | The platform on which your app or website ran; for example, web, iOS, or Android. To determine a stream's type in a report, use both platform and streamId. |\n| `streamId` | Stream ID | The numeric data stream identifier for your app or website. |\n| `streamName` | Stream name | The data stream name for your app or website. |\n| `unifiedScreenName` | Page title and screen name | The page title (web) or screen name (app) on which the event was logged. |\n\n### Custom Dimensions\n\nThe Realtime Data API can create reports on User scoped Custom Dimensions. See\n[Custom user properties](//support.google.com/analytics/answer/9269570) to learn\nmore about custom dimensions. Custom dimensions are specified in an API report\nrequest by the dimension's parameter name and scope. For example, include\n`\"customUser:last_level\"` in a Data API request to create a report for the\nUser-scoped Custom Dimension with parameter name `\"last_level\"`. This API\nrequest will fail if the property has not registered this User-scoped Custom\nDimension.\n\nThe following are the general syntax for Custom Dimensions. You can query the\n[Metadata API method](/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata) to list all\nCustom Dimensions for a Property.\n\n| Generic API Name | Description |\n|-----------------------------|----------------------------------------------------|\n| `customUser:parameter_name` | User-scoped Custom Dimension for `parameter_name`. |\n\nEvent-scoped custom dimensions aren't supported in the Realtime API.\n\nMetrics\n-------\n\nThe following metrics can be requested in reports for any property. Specify the\n\"API Name\" in a [`Metric`](/analytics/devguides/reporting/data/v1/rest/v1beta/Metric) resource's `name` field for\na column of the metric in the report response.\n\n| API Name | UI Name | Description |\n|-------------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `activeUsers` | Active users | The number of distinct users who visited your site or app. |\n| `eventCount` | Event count | The count of events. |\n| `keyEvents` | Key events | The count of key events. Marking an event as a key event affects reports from time of creation. It doesn't change historic data. You can mark any event as key in Google Analytics, and some events (such as `first_open` or `purchase`) are marked as key events by default. |\n| `screenPageViews` | Views | The number of app screens or web pages your users viewed. Repeated views of a single page or screen are counted. (screen_view + page_view events). |\n\nEvent-scoped custom metrics aren't supported in the Realtime API."]]