我使用Gapi.class.php从谷歌分析中获取数据。
这是我的PHP代码
$ga->requestReportData(xxxxx,array('sourceMedium','month','year'),array('sessions'), $sort_metric=array('month'), $filter=null, $start_date=$fromDate, $end_date=$toDate, $start_index=1, $max_results=10000);
我喜欢这个
[dimensions:gapiReportEntry:private] => Array
(
[sourceMedium] => l.facebook.com / referral
[month] => 06
[year] => 2016
)
[dimensions:gapiReportEntry:private] => Array
(
[sourceMedium] => mail.google.com / referral
[month] => 06
[year] => 2016
)
[dimensions:gapiReportEntry:private] => Array
(
[sourceMedium] => mbasic.facebook.com / referral
[month] => 06
[year] => 2016
)

我想知道如何将它们分组并计算,
Example
source Count
fb = 100
google = 50
请
答案 0 :(得分:1)
只需从查询中删除与日期相关的维度,例如month
和year
,即可获得汇总数字。
所以你的查询看起来应该是这样的,以获得预期的输出。
$ga->requestReportData(xxxxx,array('sourceMedium','pagePath'), array('pageviews'), $sort_metric=array('pageviews'), $filter=null, $start_date=$fromDate, $end_date=$toDate, $start_index=1, $max_results=10000);
请查看以下链接以供参考。