在日期范围内按自定义尺寸进行的GA4度量聚合?
我正在使用 php-data-analytics 客户端库返回a ga4 pivot报告我正在尝试获得看起来像这样的结果:
我想在每个 object_id
中返回每个 depaterange
中的汇总指标,但是我的请求似乎返回两个日期范围的聚合物,而不是分别返回。我目前拥有的是:
$args = array(
"dimensions" => [
new Dimension([ 'name' => 'nthDay' ]),
new Dimension([ 'name' => 'streamId' ]),
new Dimension([ 'name' => 'customEvent:listing_id' ])
],
"metrics" => [
new Metric([ 'name' => 'screenPageViews' ]),
new Metric([ 'name' => 'activeUsers' ]),
new Metric([ 'name' => 'userEngagementDuration' ])
],
"dimensionFilter" => new FilterExpression([
'filter' => new Filter([
'field_name' => 'streamId',
'string_filter' => new Filter\StringFilter([
'match_type' => Filter\StringFilter\MatchType::EXACT,
'value' => $stream_id,
])
])
]),
"pivots" => [
new Pivot([
'field_names' => [ 'customEvent:listing_id', 'nthDay' ],
"order_bys" => [
new OrderBy([
'desc' => false,
'dimension' => new OrderBy\DimensionOrderBy([
"dimension_name" => 'customEvent:listing_id',
"order_type" => OrderBy\DimensionOrderBy\OrderType::NUMERIC
])
]),
new OrderBy([
'desc' => false,
'dimension' => new OrderBy\DimensionOrderBy([
"dimension_name" => 'nthDay',
"order_type" => OrderBy\DimensionOrderBy\OrderType::NUMERIC
])
])
],
'metric_aggregations' => [ MetricAggregation::TOTAL ],
'limit' => 100
]),
new Pivot([
'field_names' => [ 'dateRange' ],
'limit' => 100
])
]
);
我应该如何构建 runpivortreport 请求产生上述报告?还是有更好的方法?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会说,开始简单地使它起作用而无需任何复杂性,来自此示例文档使用普通API,然后逐步构建在其上方,直到达到目标。
顺便说一句,示例正在显示您正在寻找的设计。
然后将请求主体转换为您的编程语言(PHP)。
希望这对您有帮助。
I would say start simple to make it work without any complexity following this example from the docs using normal api and then build on top of it step by step till you reach your goal.
By the way, the example is showing a design that you are looking for.
And then convert the request body to your programming language (php).
Hopefully that will help you.