在Google Analytics(分析数据API)中获取空行
很难从分析数据API(GA4)beta中获得空行。我正在按日期数组来拉动简单的流量,但是任何零流量的日期都不会返回 - 我希望它给我日期和零。
我相信应该有一个keepemptrows参数,但这似乎不起作用 - 我花了很长时间才能完成订单工作,以至于我以为我会首先检查这里,看看其他人是否有此功能。我知道我可以使用PHP代码填写缺失的日期,但我更喜欢从查询中获取它。这是我的JSON查询的PHP:
$response = $client->runReport([
'property' => 'properties/' . $_SESSION["gaid"],
'dateRanges' => [
new DateRange([
'start_date' => $mstartdate,
'end_date' => $menddate,
]),
],
'dimensions' => [new Dimension(
[
'name' => 'date',
]
),
],
'metrics' => [new Metric(
[
'name' => 'activeUsers',
'name' => 'sessions',
]
)
],
'orderBys' => [
new OrderBy([
'dimension' => new OrderBy\DimensionOrderBy([
'dimension_name' => 'date',
'order_type' => OrderBy\DimensionOrderBy\OrderType::ALPHANUMERIC
]),
'desc' => false,
])],
'keepEmptyRows'=>"1"
]);
提前致谢 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于任何寻找答案的人,该选项称为“ keepementyrows”:
来源:
不幸的是,它无法正常工作。
我要求提供7天的报告,每7行,每行包含0(以前UA都这样工作)。
相反,我有0s。
此处也提到了这个问题:
https://github.com/google/google/site-kit-kit-wp/issues/- 6623
最后,在应用来自GA的更改之前,我最终用默认数据对数组进行了预填充数组。
For anyone else looking for an answer, the option is called "keepEmptyRows":
Source:
https://github.com/googleapis/php-analytics-data/blob/master/src/V1beta/RunReportRequest.php#L642
Unfortunately, it does not work as expected.
I was asking for a 7 day report, expecting each 7 rows, each containing 0s (previously UA was working like that).
Instead I got single row with 0s.
This problem is also mentioned here:
https://github.com/google/site-kit-wp/issues/6623
In the end, I ended up pre-filling the array with the default data before applying changes that come from GA.