PHP
GAnalytics
I wrote this small class in haXe (target=>PHP) in which I use cURL.
It allows to connect to a Google Analytics account and to reach datas from Google Analytics reports.
If you're not familiar with Google Analytics check this out.
Usage :
I made this sample with two examples. The first one displays "pageViews" per "date" since 2010-07-01. In the second example, i just show how to get a single metric with its labels and datas.
package;
import php.Lib;
import GAnalytics;
class Test
{
public function new()
{
var ga = new GAnalytics();
ga.login('raza.tiana@gmail.com', '*************', '********');
var results = ga.getDimensionByMetric("pageViews", "date", "", 100, "asc,date", "2010-07-01", "2010-08-01");
var labels:Array<String> = results.label;
var datas:Array<String> = results.data;
var maxResult = labels.length - 1;
var display = '<h1>GETDIMENSIONBYMETRIC</h1>
<table>
<tr>
<td>Day</td>
<td>Page views</td>
</tr>
';
for(i in 0...maxResult)
{
display += '
<tr>
<td>'+labels[ i ]+'</td>
<td>'+datas[ i ]+'</td>
</tr>';
}
display += '</table>';
Lib.print(display);
var res2 = ga.getMetric('pageViews', '2010-07-01', '2010-08-01');
Lib.print('<hr/><h1>GETMETRIC</h1><div>'+results+'</div>');
}
static function main()
{
new Test();
}
}
View the result here.
The source code :
I hosted it on :
http://code.google.com/p/haxe-ganalytics/source/browse/trunk/GAnalytics.hx
Page(s) :
1
Contact
Follow me