Since the publication of the
first topic of creating
habra -
like statistics (which, by the way, for some reason they are not updated here), exactly a year has passed since importing data from Google Analytics.

All this year everything worked, the statistics was updated, the graphics were drawn ... until everything died. As it is inherent in Google, it died not immediately at all, but slowly, within a week. With a cursory diagnosis of the problem, it turned out that it lies in Google authentication. Considering that the authorization script was borrowed by me, there was no desire to understand it, and then it dawned on me - after all, Google
released the API for analytics! Therefore, it was decided not to file the existing version with a file, but simply to obtain the data in a civilized way, using the API, however, leaving the “structure” and highlights of the previous version.
So, for starters, as reference information I will give the links:
')
API documentation is available here.
code.google.com/intl/en_ALL/apis/analytics/docs/index.htmlIn particular, we will be interested in a class for PHP
code.google.com/p/gapi-google-analytics-php-interfaceAs well as pages describing the parameters obtained
code.google.com/intl/en_ALL/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.htmlAt once I will say that the script presented here only shows the basic principles of working with GAPI, and does not have extensive reports — only a few of the most important reports from my point of view are presented. Add any other similarity and if you have good documentation on the API should not be any difficulty. For those who have not used the previous version, it is better to get acquainted with the relevant topic in order to understand the basic principles of work and graphing. In this version, only the method of obtaining data from GA is changed. And then everything is the same - in the same way we form the same text files, in the same way graphs are built, etc.
The basic settings, as before, are specified in the config.php file - there are comments in the file, it should be clear what and why.
gapi.class.php is a class for working with API; we take it
here.well, stat.php is a script that actually generates CSV text files for building diagrams (everything is commented out there in the same way, everything is very simple)
The xml files contain chart settings. This is described in detail in the past topic. Just in case, I provide links to the description of settings:
www.amcharts.com/docs/v.1/bundle/settings/line_areawww.amcharts.com/docs/v.1/bundle/settings/pie_donutThat's all. I’ll draw your attention to the fact that stat.php is a script that imports data, and index.php is actually a regular html page that displays graphics. When executing stat.php, no errors should fall out, only in this case, we can assume that everything went fine.
Well, in the end, opening index.php we get something
like thisThe set itself is taken here,
version 3.0 :
code.google.com/p/statga/downloads/listAnd, thanks to
galo4kin , the old “branch” has been updated, without using the API. Let's call it
version 2.1 (pick up in the same place, by the link above) The changes affected only ga.php
UPDATEFixed sorting in the attendance report for the last 3 months. We are taking
version 3.1 :
code.google.com/p/statga/downloads/list