From a1ebd34d1c639e6f00bf62c47b2d0d3d4f4fd81b Mon Sep 17 00:00:00 2001 From: Kostya Kostyushko Date: Fri, 26 Jul 2013 11:57:46 -0300 Subject: [PATCH 1/2] Added Site Speed and Pageviews per Visit metrics --- Zend/Gdata/Analytics/DataQuery.php | 56 +++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/Zend/Gdata/Analytics/DataQuery.php b/Zend/Gdata/Analytics/DataQuery.php index 51c9e5c..197327e 100644 --- a/Zend/Gdata/Analytics/DataQuery.php +++ b/Zend/Gdata/Analytics/DataQuery.php @@ -140,6 +140,9 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query const METRIC_VISITORS = 'ga:visitors'; const METRIC_VISITS = 'ga:visits'; + // Page Tracking + const METRIC_PAGEVIEWS_PER_VISIT = 'ga:pageviewsPerVisit'; + // M2. Campaign const METRIC_AD_CLICKS = 'ga:adClicks'; const METRIC_AD_COST = 'ga:adCost'; @@ -181,7 +184,28 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query const METRIC_TOTAL_EVENTS = 'ga:totalEvents'; const METRIC_UNIQUE_EVENTS = 'ga:uniqueEvents'; const METRIC_EVENT_VALUE = 'ga:eventValue'; - + + // Site Speed + const METRIC_PAGE_LOAD_TIME = 'ga:pageLoadTime'; + const METRIC_PAGE_LOAD_SAMPLE = 'ga:pageLoadSample'; + const METRIC_AVG_PAGE_LOAD_TIME = 'ga:avgPageLoadTime'; + const METRIC_DOMAIN_LOOKUP_TIME = 'ga:domainLookupTime'; + const METRIC_AVG_DOMAIN_LOOKUP_TIME = 'ga:avgDomainLookupTime'; + const METRIC_PAGE_DOWNLOAD_TIME = 'ga:pageDownloadTime'; + const METRIC_AVG_PAGE_DOWNLOAD_TIME = 'ga:avgPageDownloadTime'; + const METRIC_REDIRECTION_TIME = 'ga:redirectionTime'; + const METRIC_AVG_REDIRECTION_TIME = 'ga:avgRedirectionTime'; + const METRIC_SERVER_CONNECTION_TIME = 'ga:serverConnectionTime'; + const METRIC_AVG_SERVER_CONNECTION_TIME = 'ga:avgServerConnectionTime'; + const METRIC_SERVER_RESPONSE_TIME = 'ga:serverResponseTime'; + const METRIC_AVG_SERVER_RESPONSE_TIME = 'ga:avgServerResponseTime'; + const METRIC_SPEED_METRICS_SAMPLE = 'ga:speedMetricsSample'; + const METRIC_DOM_INTERACTIVE_TIME = 'ga:domInteractiveTime'; + const METRIC_AVG_DOM_INTERACTIVE_TIME = 'ga:avgDomInteractiveTime'; + const METRIC_DOM_CONTENT_LOADED_TIME = 'ga:domContentLoadedTime'; + const METRIC_AVG_DOMCONTENT_LOADED_TIME = 'ga:avgDomContentLoadedTime'; + const METRIC_DOM_LATENCY_METRICS_SAMPLE = 'ga:domLatencyMetricsSample'; + // suported filter operators const EQUALS = "=="; const EQUALS_NOT = "!="; @@ -193,7 +217,7 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query const CONTAINS_NOT ="!@"; const REGULAR ="=~"; const REGULAR_NOT ="!~"; - + /** * @var string */ @@ -214,7 +238,7 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query * @var array */ protected $_filters = array(); - + /** * @param string $id * @return Zend_Gdata_Analytics_DataQuery @@ -239,7 +263,7 @@ public function getProfileId() */ public function addDimension($dimension) { - $this->_dimensions[$dimension] = true; + $this->_dimensions[$dimension] = true; return $this; } @@ -305,7 +329,7 @@ public function setEndDate($date) $this->setParam("end-date", $date); return $this; } - + /** * @param string $filter * @return Zend_Gdata_Analytics_DataQuery @@ -315,7 +339,7 @@ public function addFilter($filter) $this->_filters[] = array($filter, true); return $this; } - + /** * @param string $filter * @return Zend_Gdata_Analytics_DataQuery @@ -325,7 +349,7 @@ public function addOrFilter($filter) $this->_filters[] = array($filter, false); return $this; } - + /** * @param string $sort * @param boolean[optional] $descending @@ -337,7 +361,7 @@ public function addSort($sort, $descending=false) $this->_sort[] = ($descending?'-':'').$sort; return $this; } - + /** * @return Zend_Gdata_Analytics_DataQuery */ @@ -346,7 +370,7 @@ public function clearSort() $this->_sort = array(); return $this; } - + /** * @param string $segment * @return Zend_Gdata_Analytics_DataQuery @@ -366,37 +390,37 @@ public function getQueryUrl() if (isset($this->_url)) { $uri = $this->_url; } - + $dimensions = $this->getDimensions(); if (!empty($dimensions)) { $this->setParam('dimensions', implode(",", array_keys($dimensions))); } - + $metrics = $this->getMetrics(); if (!empty($metrics)) { $this->setParam('metrics', implode(",", array_keys($metrics))); } - + // profile id (ga:tableId) if ($this->getProfileId() != null) { $this->setParam('ids', 'ga:'.ltrim($this->getProfileId(), "ga:")); } - + // sorting if ($this->_sort) { $this->setParam('sort', implode(",", $this->_sort)); } - + // filtering $filters = ""; foreach ($this->_filters as $filter) { $filters.=($filter[1]===true?';':',').$filter[0]; } - + if ($filters!="") { $this->setParam('filters', ltrim($filters, ",;")); } - + $uri .= $this->getQueryString(); return $uri; } From 8befdf85f68e974c440a215356a0b68af4f760f6 Mon Sep 17 00:00:00 2001 From: Kostya Kostyushko Date: Mon, 29 Jul 2013 13:13:00 -0300 Subject: [PATCH 2/2] Added bounce rates constants --- Zend/Gdata/Analytics/DataQuery.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Zend/Gdata/Analytics/DataQuery.php b/Zend/Gdata/Analytics/DataQuery.php index 197327e..0ce4b40 100644 --- a/Zend/Gdata/Analytics/DataQuery.php +++ b/Zend/Gdata/Analytics/DataQuery.php @@ -131,6 +131,8 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query // M1. Visitor const METRIC_BOUNCES = 'ga:bounces'; + const METRIC_VISIT_BOUNCE_RATE = 'ga:visitBounceRate'; + const METRIC_ENTRANCE_BOUNCE_RATE = 'ga:entranceBounceRate'; const METRIC_ENTRANCES = 'ga:entrances'; const METRIC_EXITS = 'ga:exits'; const METRIC_NEW_VISITS = 'ga:newVisits';