|
|
Introduction
There's no official API available to get at Google Analytics reporting data, so this library was created to help you programatically get at your reporting data and use it in a third party reporting application. In particular, the WordPress Reports plugin utilizes this library to retrieve and present quick 7 day overviews in the WordPress admin dashboard.
Download the latest version of the library from SVN here: http://wordpress-reports.googlecode.com/svn/trunk/tantan/wordpress-reports/lib.googleanalytics.php
You may also need the TanTanCurl library if you don't have PEAR installed, which basically emulates the PEAR's HTTP package with libcurl.
http://tantan-toolkit.googlecode.com/svn/trunk/plugins/tantan/lib/curl.php
Documentation is sparse for now. Please see PHP file for a full list of methods and available report types.
Usage Code Example
require('lib.googleanalytics.php');
$ga = new tantan_GoogleAnalytics();
$ga->login('yourusername@gmail.com', 'yourpassword');
$accounts = $ga->getAccounts(); // retrieve accounts you have access to
print_r($accounts);
$profiles = $ga->getSiteProfiles($accountID); // retrieve site profiles for an account
print_r($profiles);
$report = $ga->getReport($profileID, '20071201', '20071214', 'pageviews'); // retrieve a pageviews report
print_r($report);
Sign in to add a comment

Ce script ne fonctionne pas chez moi : problème avec PHP :
Notice: Use of undefined constant HTTP_REQUEST_METHOD_GET - assumed 'HTTP_REQUEST_METHOD_GET' in c:\program files\easyphp1-8\www\test\lib.googleanalytics.php on line 92
I have done everything to get the Google Analytics to work on my blog. I am using wordpress 2.6.1. The feedburner works fine I guess, but the problem I face is when I have to select profile for google analytics, it only shows a combo box with select profile and default profile inspite of the fact that I have couple of profiles in my GA account.
Please help me with this, thank you.