我正在使用DougTan开发的PHP中的GoogleAnalyticsAPI类从特定的概要文件中检索分析数据。
请在此处检查URL:
http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataArticlesCode.html
当您创建类的新实例时,您可以添加配置文件ID、您的Google帐户+密码、日期范围以及您希望从分析中获得的任何维度和指标。
例如,我想看看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'
)
);
现在您知道了这个API类的工作原理,我想解决我的问题。
速度。从分析数据库中检索多种类型的数据需要花费大量的时间,尤其是在构建具有不同度量/维度的不同阵列时。我怎样才能加快这个过程?
是否可以将所有可能的数据存储在缓存中,这样我就可以在不反复加载数据的情况下检索数据?