gpt4 book ai didi

google-analytics-firebase - 谷歌分析 API V4 : includeEmptyRows: 'true' , 不工作

转载 作者:行者123 更新时间:2023-12-02 00:45:44 25 4
gpt4 key购买 nike

我正在将我的应用程序迁移到 V4,问题是您需要将 includeEmptyRows 设置为 TRUE,而这正是我刚刚完成的。然而,空行根本没有填充。

function queryReports() {
gapi.client.request({
path: '/v4/reports:batchGet',
root: 'https://analyticsreporting.googleapis.com/',
method: 'POST',
body: {
reportRequests: [
{
**includeEmptyRows: 'true',**
//**this above for empty rows

viewId: VIEW_ID,
dateRanges: [
{
startDate: startDate0,
endDate: endDate0
}
],
//**below samplimg levels
samplingLevel: 'LARGE',
//request metrics here
metrics: [
{
expression: 'ga:sessions',
}
,
{
expression:'ga:goalCompletionsAll',
},
{
expression:'ga:transactionRevenue',
},
{
expression:'ga:transactions',
},
],
//request dimensions here
dimensions: [
{
name:'ga:channelGrouping',
},

{
name:'ga:yearMonth',
},
],
}
]
}
}).then(displayResults, console.error.bind(console));
}

我得到的只是非空行值,因此对于没有任何特定 channel 数据的月份,我会直接跳过 :/

不确定这里出了什么问题,我遵循了文档中的规范,但它根本不起作用。

希望有人能帮帮我,

非常感谢J.

最佳答案

文档可能会好很多 - 不幸的是,它会让人们相信您会为每个具有零值的维度组合返回行。不幸的是,事实并非如此。如果您要从查询中排除 ChannelGrouping,您确实会获得日期范围内所有 yearMonth 值的行,即使有 0 个 session 。

换句话说,当您在查询中仅包含日期维度(而不是时间维度)时,这会像您预期的那样工作。

我认为这是因为每个日期段内每个维度的基数未知。您是否希望每个 yearMonth 和 ChannelGrouping 组合都有 0 个 session 的行?如果添加国家和城市作为维度会怎样?

有可能获得您想要的结果,而不是通过针对 API 的单个查询。以下是使用 Analytics Canvas 的步骤概要,但您可以使用 JavaScript(或进行 API 调用的任何语言)和 SQL 自行执行相同的步骤。

workflow to includeEmptyRows with various dimensions using Analytics Canvas

要获得您想要的结果,请执行以下 3 个查询:

1) yearMonth and sessions with empty rows:

2) channelGrouping and sessions over the time period

3) yearMonth, channelGrouping, and sessions (您的查询如上所示):

现在执行 cross join在查询 1 和 2 上,从输出中删除 session 。您将有一个表格,其中包含您的时间段内 yearMonth 和 channelGrouping 的所有组合。我们称此为表 4。

result of cross join and dropping sessions column

接下来对表 4 和查询 3 执行左外连接,从查询 3 中删除 yearMonth 和 channelGrouping。

left outer join dropping columns

您现在有表 5,其中包含 yearMonth 和 channelGrouping 的每个组合、该组合中存在 session 的 session 的值以及其余的空值。

最后用零替换空值,你就得到了你想要的数据集。

isnull([Original.sessions], 0)

includeEmptyRows final result

关于google-analytics-firebase - 谷歌分析 API V4 : includeEmptyRows: 'true' , 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44026186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com