试用 Google Analytics 的 MCP 服务器。从
GitHub 安装,并参阅
公告了解详情。
Dimension
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
“维度”是指数据的属性。例如,“城市”维度表示事件来自哪个城市。报告响应中的维度值为字符串;例如,“城市”可以是“巴黎”或“纽约”。请求最多可以包含 9 个维度。
字段 |
name |
string
维度的名称。如需查看核心报告方法(例如 runReport 和 batchRunReports )支持的维度名称列表,请参阅 API 维度。如需查看 runRealtimeReport 方法支持的维度名称列表,请参阅实时维度。如需查看 runFunnelReport 方法支持的维度名称列表,请参阅漏斗维度。 如果指定了 dimensionExpression ,name 可以是允许的字符集中的任何字符串。例如,如果 dimensionExpression 串联了 country 和 city ,您可以将该维度称为 countryAndCity 。您选择的维度名称必须与正则表达式 ^[a-zA-Z0-9_]$ 匹配。 dimensionFilter 、orderBys 、dimensionExpression 和 pivots 中的 name 会引用尺寸。
|
dimensionExpression |
object (DimensionExpression )
一个维度可以是多个维度的表达式的结果。例如,“国家/地区、城市”维度:concatenate(country, ", ", city)。
|
DimensionExpression
用于表示由多个维度的公式计算得出的维度。示例用法:1) lowerCase(dimension) 2) concatenate(dimension1, symbol, dimension2)。
JSON 表示法 |
{
// Union field one_expression can be only one of the following:
"lowerCase": {
object (CaseExpression )
},
"upperCase": {
object (CaseExpression )
},
"concatenate": {
object (ConcatenateExpression )
}
// End of list of possible types for union field one_expression .
} |
字段 |
联合字段 one_expression 。为 DimensionExpression 指定一种维度表达式。one_expression 只能是下列其中一项: |
lowerCase |
object (CaseExpression )
用于将维度值转换为小写形式。
|
upperCase |
object (CaseExpression )
用于将维度值转换为大写形式。
|
concatenate |
object (ConcatenateExpression )
用于将维度值合并到单个维度。例如,“国家/地区、城市”维度:concatenate(country, ", ", city)。
|
CaseExpression
JSON 表示法 |
{
"dimensionName": string
} |
字段 |
dimensionName |
string
维度的名称。该名称必须回引用请求的“dimensions”字段中的名称。
|
ConcatenateExpression
JSON 表示法 |
{
"dimensionNames": [
string
],
"delimiter": string
} |
字段 |
dimensionNames[] |
string
维度的名称。这些名称必须与请求的“维度”字段中的名称相关联。
|
delimiter |
string
放置在维度名称之间的分隔符。 分隔符通常是单个字符(例如“|”或“,”),但也可以是较长的字符串。如果维度值包含分隔符,则响应中会同时显示这两者,没有区别。例如,如果维度 1 的值为“US,FR”,维度 2 的值为“JP”,分隔符为“,”,则响应将包含“US,FR,JP”。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["Dimensions represent data attributes, like city or country, and are limited to 9 per request."],["You can create custom dimensions using expressions that manipulate existing dimensions (e.g., lowercase, concatenate)."],["Dimension expressions can combine multiple dimensions with delimiters, such as joining country and city with a comma."],["Dimension names in expressions should refer to existing dimension names defined in the request."],["When using delimiters, ensure they don't clash with values within your dimension data to avoid ambiguity."]]],["This document outlines the structure and usage of dimensions in data reporting, focusing on creating custom dimensions. Dimensions are data attributes, like \"city.\" You can define a `dimension` with a `name` and an optional `dimensionExpression`. `DimensionExpression` allows combining or modifying existing dimensions using `lowerCase`, `upperCase`, or `concatenate` functions. `CaseExpression` changes dimension cases. `ConcatenateExpression` merges dimension values with a specified `delimiter`. Each dimension name is a string with allowed characters.\n"]]