From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../manual/core/en/zend.gdata.analytics.html | 176 +++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 zend/documentation/manual/core/en/zend.gdata.analytics.html (limited to 'zend/documentation/manual/core/en/zend.gdata.analytics.html') diff --git a/zend/documentation/manual/core/en/zend.gdata.analytics.html b/zend/documentation/manual/core/en/zend.gdata.analytics.html new file mode 100644 index 0000000..3030280 --- /dev/null +++ b/zend/documentation/manual/core/en/zend.gdata.analytics.html @@ -0,0 +1,176 @@ + + + + + Using Google Analytics - Zend Framework Manual + + + + + + + + +
+ + + + + + + + +
+ Zend_Gdata + + + + +
+
+

Using Google Analytics

+ + +

+ The Google Analytics API allows client applications to + request data, saved in the analytics accounts. +

+ +

+ See » http://code.google.com/apis/analytics/docs/gdata/v2/gdataOverview.html + for more information about the Google Analytics API. +

+ +

Retrieving account data

+ + +

+ Using the account feed, you are able to retrieve a list of all the accounts available to a specified user. +

+ +
  1. $service = Zend_Gdata_Analytics::AUTH_SERVICE_NAME;
  2. +
  3. $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, $service);
  4. +
  5. $analytics = new Zend_Gdata_Analytics($client)
  6. +
  7. $accounts = $analytics->getAccountFeed();
  8. +
  9.  
  10. +
  11. foreach ($accounts as $account) { 
  12. +
  13.   echo "\n{$account->title}\n";
  14. +
  15. }
+ + +

+ The $analytics->getAccountFeed() call, results in a + Zend_Gdata_Analytics_AccountFeed object that contains + Zend_Gdata_Analytics_AccountEntry objects. Each of this + objects represent a google analytics account. +

+
+ +

Retrieving report data

+ + +

+ Besides the account feed, google offers a data feed, to retrieve report data using + the Google Analytics API. To easily request for these reports, + Zend_Gdata_Analytics offers a simple query construction interface. You can use all + the » metrics + and dimensions specified by the API. Additionaly you can apply some » filters + to retrieve some » common + data or even complex results. +

+ +
  1. $query = $service->newDataQuery()->setProfileId($profileId) 
  2. +
  3.   ->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_BOUNCES)   
  4. +
  5.   ->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_VISITS)
  6. +
  7.   ->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_MEDIUM) 
  8. +
  9.   ->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_SOURCE) 
  10. +
  11.   ->addFilter("ga:browser==Firefox") 
  12. +
  13.   ->setStartDate('2011-05-01')   
  14. +
  15.   ->setEndDate('2011-05-31')   
  16. +
  17.   ->addSort(Zend_Gdata_Analytics_DataQuery::METRIC_VISITS, true) 
  18. +
  19.   ->addSort(Zend_Gdata_Analytics_DataQuery::METRIC_BOUNCES, false) 
  20. +
  21.   ->setMaxResults(50);
  22. +
  23.  
  24. +
  25. $result = $analytics->getDataFeed($query);
  26. +
  27. foreach($result as $row){ 
  28. +
  29.   echo $row->getMetric('ga:visits')."\t"
  30. +
  31.   echo $row->getValue('ga:bounces')."\n"
  32. +
  33. }
+ +
+
+
+ + + + + + + + + +
+ Zend_Gdata + + + + +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.3