可嵌入Google Analytics(分析)" Flair&quot ;? [英] Embeddable Google Analytics "Flair"?

查看:109
本文介绍了可嵌入Google Analytics(分析)" Flair&quot ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

既然Google Analytics(分析) 有官方API ,是否有任何实现小型,简约的Flair类似的片段,显示可自定义的统计选择,例如今天和本周的访问者,也可能是一个或两个图表 - 嵌入到自己的管理员面板和后端应用程序?



我理想地寻找基于PHP的实现;完美的解决方案将能够独立运行(没有大的依赖关系),只需要放入API密钥/登录数据即可开始使用。干净的代码和PHP 5 OOP将是一个优点。

解决方案

GAPI听起来像你需要的。 b

GAPI(称为'g,a,p,i')是Google Analytics(分析)PHP5界面。



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'网页浏览:'。 $ result-> getPageviews()。 '';
echo'访问:'。 $ result-> getVisits()。 '< br />';
}

echo'< p>总浏览量:'。 $ ga-> getPageviews()。 '总访问次数:'。 $ ga-> getVisits()。 < / p为H.;


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.

解决方案

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

这篇关于可嵌入Google Analytics(分析)&quot; Flair&quot ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆