Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

php - Embeddable Google Analytics "Flair"?

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

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

1 Reply

0 votes
by (71.8m points)

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>';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...