Google Analytics API Authentication Speedup

Posted by Paulo on Stack Overflow See other posts from Stack Overflow or by Paulo
Published on 2010-03-12T10:38:05Z Indexed on 2010/03/12 10:57 UTC
Read the original article Hit count: 413

Filed under:
|
|
|
|

I'm using a Google Analytics API Class in PHP made by Doug Tan to retrieve Analytics data from a specific profile.

Check the url here: http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataArticlesCode.html

When you create a new instance of the class you can add the profile id, your google account + password, a daterange and whatever dimensions and metrics you want to pick up from analytics.

For example i want to see how many people visited my website from different country's in 2009.

//make a new instance from the class
$ga = new GoogleAnalytics($email,$password);

//website profile example id
$ga->setProfile('ga:4329539');

//date range
$ga->setDateRange('2010-02-01','2010-03-08');

//array to receive data from metrics and dimensions
$array = $ga->getReport(
        array('dimensions'=>('ga:country'),
        'metrics'=>('ga:visits'),
        'sort'=>'-ga:visits'
        )
);

Now you know how this API class works, i'd like to adress my problem.

Speed. It takes alot of time to retrieve multiple types of data from the analytics database, especially if you're building different arrays with different metrics/dimensions. How can i speed up this process?

Is it possible to store all the possible data in a cache so i am able to retrieve the data without loading it over and over again?

© Stack Overflow or respective owner

Related posts about api

Related posts about google