gpt4 book ai didi

php - Google Analytics API 获取具有维度的数据

转载 作者:可可西里 更新时间:2023-10-31 22:09:44 25 4
gpt4 key购买 nike

我使用 Google Analitycs API。我想像这样在一次 API 调用中获取每天过去 7 天的所有 session :

[第 1 天] -> 10

[第 2 天] -> 100...

我用这个:

$service->data_ga->get('ga:'.$profile['id'],'7daysAgo','today','ga:sessions');

它工作正常但返回总和。我已经检查过 https://ga-dev-tools.appspot.com/query-explorer/对于我需要的,我应该添加指标 ga:date 这样每天的日期就不是全部。

我尝试在行尾添加指标:

$service->data_ga->get('ga:'.$profile['id'],'7daysAgo','today','ga:sessions','ga:date');

我得到了这个错误:

未捕获异常“Google_Exception”,消息“(get) missing required param: 'start-date'”在

最佳答案

答案是这样的:

$SecondaryParams = array('dimensions' => 'ga:date');

$results = $service->data_ga->get('ga:'.$profile['id'],
'7daysAgo',
'today',
'ga:sessions',
$SecondaryParams);

将维度作为数组发送。

关于php - Google Analytics API 获取具有维度的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41002973/

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