/** The page query * @access public * @throws Pas_Analytics_Exception */ public function pageAction() { $analytics = new Pas_Analytics_Gateway($this->_ID, $this->_pword); $analytics->setProfile(25726058); $timeframe = new Pas_Analytics_Timespan(); $timeframe->setTimespan($this->getParam('timespan')); $dates = $timeframe->getDates(); $analytics->setStart($dates['start']); $analytics->setEnd($dates['end']); $analytics->setMetrics(array(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS, Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, Zend_Gdata_Analytics_DataQuery::METRIC_UNIQUE_PAGEVIEWS, Zend_Gdata_Analytics_DataQuery::METRIC_AVG_TIME_ON_PAGE, Zend_Gdata_Analytics_DataQuery::METRIC_ENTRANCES, Zend_Gdata_Analytics_DataQuery::METRIC_EXIT_RATE, Zend_Gdata_Analytics_DataQuery::METRIC_BOUNCES)); $analytics->setDimensions(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_TITLE, Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH)); if (is_null($this->getParam('url'))) { throw new Pas_Analytics_Exception('A path must be set'); } else { $analytics->setFilters(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . Zend_Gdata_Analytics_DataQuery::EQUALS . base64_decode(rawurldecode($this->getParam('url'))))); } $analytics->setMax(20); $analytics->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS); $analytics->setSortDirection(true); $this->view->results = $analytics->getData(); $this->view->total = (int) $analytics->getTotal(); $this->view->path = $this->getParam('url'); }
/** Get the data from google's api * @access public * @return \Pas_View_Helper_GaContentMetrics */ public function getGaData() { $analytics = new Pas_Analytics_Gateway($this->getId(), $this->getPassword()); $analytics->setProfile($this->getProfile()); $timeframe = new Pas_Analytics_Timespan($this->getTimeSpan()); $dates = $timeframe->getDates(); $analytics->setStart($dates['start']); $analytics->setEnd($dates['end']); $analytics->setMetrics(array(Zend_Gdata_Analytics_DataQuery::METRIC_SPEED_AVG_PAGE_LOAD_TIME, Zend_Gdata_Analytics_DataQuery::METRIC_SPEED_METRICS_SAMPLE)); $analytics->setDimensions(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH)); $analytics->setFilters(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . Zend_Gdata_Analytics_DataQuery::EQUALS . $this->_path)); $analytics->setMax($this->getLimit()); $analytics->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_SPEED_AVG_PAGE_LOAD_TIME); $analytics->setSortDirection(true); $this->_results = $analytics->getData(); $this->_total = $analytics->getTotal(); return $this; }
/** Get data from the api * @access public * @return \Pas_View_Helper_GaContentSearch */ public function getGaData() { $analytics = new Pas_Analytics_Gateway($this->getId(), $this->getPassword()); $analytics->setProfile($this->getProfile()); $timeframe = new Pas_Analytics_Timespan($this->getTimeSpan()); $dates = $timeframe->getDates(); $analytics->setStart($dates['start']); $analytics->setEnd($dates['end']); $analytics->setMetrics(array(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS, Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, Zend_Gdata_Analytics_DataQuery::METRIC_UNIQUE_PAGEVIEWS, Zend_Gdata_Analytics_DataQuery::METRIC_AVG_TIME_ON_PAGE, Zend_Gdata_Analytics_DataQuery::METRIC_ENTRANCES)); $analytics->setDimensions(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_KEYWORD, Zend_Gdata_Analytics_DataQuery::DIMENSION_SOURCE)); $analytics->setFilters(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_KEYWORD . Zend_Gdata_Analytics_DataQuery::REGULAR_NOT . '(not set)', Zend_Gdata_Analytics_DataQuery::DIMENSION_KEYWORD . Zend_Gdata_Analytics_DataQuery::REGULAR_NOT . '(not provided)', Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . Zend_Gdata_Analytics_DataQuery::REGULAR . $this->getPath())); $analytics->setMax($this->getLimit()); $analytics->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS); $analytics->setSortDirection(true); $this->_results = $analytics->getData(); $this->_total = $analytics->getTotal(); return $this; }
/** Get data by a city * @access public */ public function cityAction() { $analytics = new Pas_Analytics_Gateway($this->_ID, $this->_pword); $analytics->setProfile(25726058); $timeframe = new Pas_Analytics_Timespan(); $timeframe->setTimespan($this->getParam('timespan')); $dates = $timeframe->getDates(); $analytics->setStart($dates['start']); $analytics->setEnd($dates['end']); $analytics->setMetrics(array(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS, Zend_Gdata_Analytics_DataQuery::METRIC_VISITS, Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, Zend_Gdata_Analytics_DataQuery::METRIC_BOUNCES, Zend_Gdata_Analytics_DataQuery::METRIC_AVG_TIME_ON_SITE)); $analytics->setDimensions(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_CITY)); $analytics->setMax(100); $analytics->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_VISITORS); $analytics->setSortDirection(true); $analytics->setStartIndex($this->getStart()); $this->view->results = $analytics->getData(); $paginator = Zend_Paginator::factory((int) $analytics->getTotal()); $paginator->setCurrentPageNumber((int) $this->getPage())->setItemCountPerPage((int) self::MAX_RESULTS); $this->view->paginator = $paginator; }
/** The activities action * @access public */ public function activitiesAction() { $analytics = new Pas_Analytics_Gateway($this->_ID, $this->_pword); $analytics->setProfile(25726058); $timeframe = new Pas_Analytics_Timespan(); $timeframe->setTimespan($this->getParam('timespan')); $dates = $timeframe->getDates(); $analytics->setStart($dates['start']); $analytics->setEnd($dates['end']); $analytics->setMetrics(array(Zend_Gdata_Analytics_DataQuery::METRIC_SOCIAL_ACTIVITIES)); $analytics->setDimensions(array(Zend_Gdata_Analytics_DataQuery::DIMENSION_SOCIAL_ACTIVITY_CONTENT_URL, Zend_Gdata_Analytics_DataQuery::DIMENSION_SOCIAL_ACTIVITY_POST, Zend_Gdata_Analytics_DataQuery::DIMENSION_SOCIAL_ACTIVITY_NETWORK_ACTION, Zend_Gdata_Analytics_DataQuery::DIMENSION_SOCIAL_ACTIVITY_DISPLAY_NAME, Zend_Gdata_Analytics_DataQuery::DIMENSION_SOCIAL_ACTIVITY_ENDORSING_URL)); $analytics->setMax(self::MAX_RESULTS); $analytics->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_SOCIAL_ACTIVITIES); $analytics->setSortDirection(true); $analytics->setStartIndex($this->getStart()); $this->view->results = $analytics->getData(); $paginator = Zend_Paginator::factory((int) $analytics->getTotal()); $paginator->setCache($this->getCache()); $paginator->setCurrentPageNumber((int) $this->getPage())->setItemCountPerPage((int) self::MAX_RESULTS); $this->view->paginator = $paginator; }