如何使用GAPI(Google Analytics)获取网站前10页(根据视图)?

时间:2014-05-07 07:32:27

标签: php google-analytics google-analytics-api

我是GAPI的新手。我想在移动设备和桌面上使用GAPI找到前10页的网站..我编写了这个..

<?php
define('ga_email','xxxxxxxxxxxxxx@gmail.com');
define('ga_password','xxxxxxxxxxxxxxx');
define('ga_profile_id','xxxxxxxxxxx');

require 'gapi.class.php';

$ga = new gapi(ga_email,ga_password);

$ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pageviews','visits'));

//echo '<pre>';print_r($ga->getResults());exit;

?>
<table>
   <tr>
     <th>Browser &amp; Browser Version</th>
     <th>Pageviews</th>
     <th>Visits</th>
   </tr>
<?php
  foreach($ga->getResults() as $result):
?>
  <tr>
    <td><?php echo $result ?></td>
    <td><?php echo $result->getPageviews() ?></td>
    <td><?php echo $result->getVisits() ?></td>
  </tr>
<?php
  endforeach
?> 

0 个答案:

没有答案