我正在尝试使用GAPI显示前5个非移动浏览器。
我似乎找不到这样做的方法,这甚至可能吗?
这就是我获得移动访问百分比的方式:
$ga->requestReportData(GA_PROFILE_ID, array("isMobile"), array("visits"), '-visits', null, $startdate, $enddate);
foreach ($ga->getResults() AS $result) {
if ((string)$result == "Yes") $mobile["yes"] = $result->getVisits();
else $mobile["no"] = $result->getVisits();
}
答案 0 :(得分:1)
这就是我最终做到的方式:
public function getDevices($max = 5) {
$this->ga->requestReportData($this->profileid, array('mobileDeviceInfo'), array('visits'), '-visits', 'mobileDeviceInfo != (not set) && mobileDeviceInfo != (not provided)', $this->startdate, $this->enddate, 1, $max);
foreach ($this->ga->getResults() as $result) {
$device[] = (string)$result;
$visits[] = $result->getVisits();
}
if (!isset($device) OR !isset($visits)) {
$device[] = "Niet genoeg data beschikbaar";
$visits[] = "0";
}
$return = array("device" => $device, "visits" => $visits);
return $return;
}