我使用Google Analitycs API。我希望每天最后7天获得所有会话,只需一次API调用:
[第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)缺少必需的参数:'start-date''
答案 0 :(得分:6)
答案是:
$SecondaryParams = array('dimensions' => 'ga:date');
$results = $service->data_ga->get('ga:'.$profile['id'],
'7daysAgo',
'today',
'ga:sessions',
$SecondaryParams);
将尺寸发送为数组。