我正在使用由Doug Tan製作的Google Analytics API類來從特定配置文件中檢索Google Analytics數據。谷歌分析API身份驗證加速
檢查這裏的網址:http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataArticlesCode.html
當你創建一個類的新實例,你可以添加個人資料的ID,你的谷歌賬戶+口令,日期範圍和您希望從分析拿起任何維度和指標。
例如,我想看看有多少人訪問了來自不同國家的我的網站在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類的工作,我想ADRESS我的問題。
速度。從分析數據庫檢索多種類型的數據需要花費大量時間,特別是如果您使用不同的度量標準/維度構建不同的數組時。我如何加快這個過程?
是否有可能將所有可能的數據存儲在緩存中,以便我能夠檢索數據而無需一遍又一遍地加載它?
嗨@PaulH,我可以向您瞭解您是否關心從Google獲取數據1)速度慢還是2)會降低您的網站速度?對我來說2)更重要,它看起來像谷歌已經緩存結果,所以現在唯一的問題是如何控制緩存過程 – ericn 2013-02-15 03:43:31