Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Now that Google Analytics has an official API, are there any implementations of a small, minimalistic "Flair" like snippet showing a customizable selection of stats, say for example, today's and the week's visitors, and maybe a chart or two - to embed into one's own admin panels and back-end applications?

I am ideally looking for implementations based on PHP; the perfect solution would be able to run stand-alone (no big dependencies) and require just to put in the API key / login data to get started. Clean code and PHP 5 OOP would be a plus.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
240 views
Welcome To Ask or Share your Answers For Others

1 Answer

GAPI sound like what you need.

GAPI (said 'g,a,p,i') is the Google Analytics PHP5 Interface.

http://code.google.com/p/gapi-google-analytics-php-interface/

use it as follows:

$ga = new gapi('email@yourdomain.com','password');

$ga->requestReportData(145141242,array('browser','browserVersion'),array('pageviews','visits'));

foreach($ga->getResults() as $result)
{
  echo '<strong>'.$result.'</strong><br />';
  echo 'Pageviews: ' . $result->getPageviews() . ' ';
  echo 'Visits: ' . $result->getVisits() . '<br />';
}

echo '<p>Total pageviews: ' . $ga->getPageviews() . ' total visits: ' . $ga->getVisits() . '</p>';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...