问题描述
现在 Google Analytics 有了官方 API,是否有任何实现小而简约的天赋"之类的片段,显示可自定义的统计数据选择,例如今天和本周的访问者,可能还有一两个图表 - 嵌入到自己的管理中面板和后端应用程序?
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?
我正在理想地寻找基于 PHP 的实现;完美的解决方案将能够独立运行(没有大的依赖)并且只需要输入 API 密钥/登录数据即可开始.干净的代码和 PHP 5 OOP 将是一个加分项.
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.
推荐答案
GAPI 听起来像您所需要的.
GAPI sound like what you need.
GAPI(表示g,a,p,i")是 Google Analytics PHP5 接口.
GAPI (said 'g,a,p,i') is the Google Analytics PHP5 Interface.
http://code.google.com/p/gapi-google-analytics-php-interface/
如下使用:
$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>';
这篇关于可嵌入的谷歌分析“天赋"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!