forked from erebusnz/gapi-google-analytics-php-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.report.php
41 lines (38 loc) · 822 Bytes
/
example.report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require 'gapi.class.php';
define('ga_profile_id','your profile id');
$ga = new gapi("XXXXXXXX@developer.gserviceaccount.com", "key.p12");
$ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pageviews','visits'));
?>
<table>
<tr>
<th>Browser & 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
?>
</table>
<table>
<tr>
<th>Total Results</th>
<td><?php echo $ga->getTotalResults() ?></td>
</tr>
<tr>
<th>Total Pageviews</th>
<td><?php echo $ga->getPageviews() ?>
</tr>
<tr>
<th>Total Visits</th>
<td><?php echo $ga->getVisits() ?></td>
</tr>
</table>