Question

I am trying to display the top 5 of non-mobile browsers with GAPI. I can't seem to find a way of doing this, is this even possible?
This is how I get the percentage of mobile visits:

$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();

}
Was it helpful?

Solution

This is how I ended up doing it:

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top