Example #1
0
 public function init()
 {
     if (JRequest::getVar('code', null) == null) {
         header('Location: ' . GAnalyticsDataHelper::getClient()->createAuthUrl());
     } else {
         $this->items = $this->get('Items');
     }
 }
Example #2
0
 public function getItems()
 {
     // 		$row = $this->getTable('Profile', 'GAnalyticsTable');
     // 		$row->id = 0;
     // 		$row->accountID = 'sdfsdf';
     // 		$row->profileID = 123413;
     // 		$row->webPropertyId = 234234234;
     // 		$row->accountName = 'sdfsdf';
     // 		$row->profileName ='sdfsf';
     // 		$row->token = 'sdfsdf';
     // 		$row->startDate = JFactory::getDate()->toSql();
     // 		return array($row);
     return GAnalyticsDataHelper::getAccounts();
 }
Example #3
0
function checkDB()
{
    $tmp = array();
    $model = JModelLegacy::getInstance('Profiles', 'GAnalyticsModel');
    $results = $model->getItems();
    if (empty($results)) {
        $tmp[] = array('name' => 'DB Entries Check', 'description' => 'No profiles found.', 'status' => 'warning', 'solution' => 'Import your google analytics profiles.');
    } else {
        foreach ($results as $result) {
            $data = GAnalyticsDataHelper::getData($result, array('date'), array('visits'));
            if ($data === null) {
                $message = array_shift(JFactory::getApplication()->getMessageQueue());
                if (key_exists('message', $message)) {
                    $message = $message['message'];
                } else {
                    $message = print_r($message, true);
                }
                $desc = "An error occurred when reading statistic data from profile " . $result->profileName . ":<br>" . $message;
                $solution = "<ul><li>If the error is the same as in the connection test use the solution described there.</li>";
                $solution .= "<li><b>If the problem still exists check the forum at <a href=\"http://joomla.digital-peak.com\">joomla.digital-peak.com</a>.</b></li></ul>";
                $status = 'failure';
            } else {
                if (empty($data)) {
                    $solution = 'Make sure the tracking plugin is enabled. If it is a brand new account come tomorrow again till google processed your data :-).';
                    $status = 'warning';
                    $desc = 'GAnalytics could fetch the statistics data without any problems from profile ' . $result->profileName . '. But the result was empty.';
                } else {
                    $solution = '';
                    $status = 'ok';
                    $desc = 'GAnalytics could read the statistic data without any problems from profile ' . $result->profileName . '.';
                }
            }
            $tmp[] = array('name' => $result->profileName . ' Check', 'description' => $desc, 'status' => $status, 'solution' => $solution);
        }
    }
    return $tmp;
}
Example #4
0
 public function getStatsData()
 {
     $params = $this->getState('params');
     $startDate = JFactory::getDate();
     $startDate->modify('-1 day');
     $endDate = JFactory::getDate();
     $endDate->modify('-1 day');
     if ($params->get('daterange', 'month') == 'advanced') {
         $tmp = $params->get('advancedDateRange', null);
         if (!empty($tmp)) {
             $startDate = JFactory::getDate(strtotime($tmp));
         } else {
             $tmp = $params->get('startdate', null);
             if (!empty($tmp)) {
                 $startDate = JFactory::getDate($tmp);
             }
             $tmp = $params->get('enddate', null);
             if (!empty($tmp)) {
                 $endDate = JFactory::getDate($tmp);
             }
         }
     } else {
         $range = '';
         switch ($params->get('daterange', 'month')) {
             case 'day':
                 $range = '-1 day';
                 break;
             case 'week':
                 $range = '-1 week';
                 break;
             case 'month':
                 $range = '-1 month';
                 break;
             case 'year':
                 $range = '-1 year';
                 break;
         }
         $startDate = JFactory::getDate(strtotime($range));
     }
     $dimensions = array();
     $metrics = array();
     $sort = array();
     if ($params->get('type', 'visitsbytraffic') == 'advanced') {
         $dimensions = $params->get('dimensions', array('ga:date'));
         $metrics = $params->get('metrics', array('ga:visits'));
         $sort = $params->get('sort', array());
     } else {
         switch ($params->get('type', 'visitsbytraffic')) {
             case 'visits':
                 $dimensions[] = 'ga:date';
                 $metrics[] = 'ga:visits';
                 $metrics[] = 'ga:newVisits';
                 $sort[] = 'ga:date';
                 break;
             case 'visitsbytraffic':
                 $dimensions[] = 'ga:source';
                 $metrics[] = 'ga:visits';
                 $metrics[] = 'ga:newVisits';
                 $sort[] = '-ga:visits';
                 break;
             case 'visitsbybrowser':
                 $dimensions[] = 'ga:browser';
                 $metrics[] = 'ga:visits';
                 $metrics[] = 'ga:newVisits';
                 $sort[] = '-ga:visits';
                 break;
             case 'visitsbycountry':
                 $dimensions[] = 'ga:country';
                 $metrics[] = 'ga:visits';
                 $sort[] = '-ga:visits';
                 break;
             case 'timeonsite':
                 $dimensions[] = 'ga:region';
                 $metrics[] = 'ga:timeOnSite';
                 $sort[] = '-ga:timeOnSite';
                 break;
             case 'toppages':
                 $dimensions[] = 'ga:pagePath';
                 $metrics[] = 'ga:pageviews';
                 $sort[] = '-ga:pageviews';
                 break;
         }
     }
     $max = $params->get('max', 1000);
     if (JRequest::getVar('type', null) == 'visitor') {
         $dimensions = array('ga:date');
         $metrics = array('ga:newVisits', 'ga:visits');
         $sort = array('ga:date');
         $max = 1000;
     }
     if (JRequest::getVar('start-date', null) != null) {
         $startDate = JFactory::getDate(JRequest::getVar('start-date', null));
         $startDate->setTime(0, 0);
     }
     if (JRequest::getVar('end-date', null) != null) {
         $endDate = JFactory::getDate(JRequest::getVar('end-date', null));
         $endDate->setTime(0, 0);
     }
     $filter = null;
     if ($params->get('filterType', '') == 'page') {
         $uri = JFactory::getURI();
         $filter = 'ga:pagePath==' . $uri->getPath() . '?' . $uri->getQuery();
     }
     if ($params->get('filterType', '') == 'advanced') {
         $filter = GAnalyticsHelper::render($params->get('filter', null), array('userId' => JFactory::getUser()->id, 'username' => strtolower(JFactory::getUser()->username)));
     }
     return GAnalyticsDataHelper::getData($this->getProfile(), $dimensions, $metrics, $startDate, $endDate, $sort, $filter, $max);
 }
Example #5
0
<?php

/**
 * @package		GAnalytics
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2015 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die;
echo GAnalyticsDataHelper::convertToJsonResponse($this->profile, $this->data, JRequest::getVar('source') == 'referrer' ? 'list' : 'image');
Example #6
0
<?php

/**
 * @package		GAnalytics
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2015 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die;
echo GAnalyticsDataHelper::convertToJsonResponse($this->profile, $this->data, $this->params->get('mode', 'list'));
Example #7
0
 private function getStats($dimensions, $metrics, $sort, $max, $type)
 {
     $store = $this->getStoreId($type);
     if (isset($this->cache[$store])) {
         return $this->cache[$store];
     }
     $start = JFactory::getDate($this->state->get('filter.search_start'));
     $end = JFactory::getDate($this->state->get('filter.search_end'));
     $filter = $this->state->get('filter.search');
     if (!empty($filter)) {
         $filter = 'ga:pageTitle=@' . $filter . ',ga:pagePath=@' . $filter;
     } else {
         $filter = null;
     }
     $this->cache[$store] = GAnalyticsDataHelper::getData($this->getProfile(), $dimensions, $metrics, $start, $end, $sort, $filter, $max);
     return $this->cache[$store];
 }
Example #8
0
 public function getStatsData()
 {
     $view = JTable::getInstance('StatsView', 'GAnalyticsTable');
     $view->load(JRequest::getInt('id'));
     $profile = JTable::getInstance('Profile', 'GAnalyticsTable');
     $profile->load(JRequest::getInt('gaid', 0));
     $s = JRequest::getVar('start-date', null);
     $start = $s == null ? null : JFactory::getDate($s);
     $e = JRequest::getVar('end-date', null);
     $end = $e == null ? null : JFactory::getDate($e);
     return GAnalyticsDataHelper::getData($profile, $view->dimensions, $view->metrics, $start, $end, $view->sort, $view->filter, $view->max_result);
 }
Example #9
0
 private function getStats($dimensions, $metrics, $sort, $max, $type)
 {
     $store = $this->getStoreId($type);
     if (isset($this->cache[$store])) {
         return $this->cache[$store];
     }
     $start = JFactory::getDate($this->state->get('filter.search_start'));
     $end = JFactory::getDate($this->state->get('filter.search_end'));
     $filter = 'ga:pagePath==' . base64_decode(JRequest::getVar('path', '', null, 'BASE64'));
     $this->cache[$store] = GAnalyticsDataHelper::getData($this->getProfile(), $dimensions, $metrics, $start, $end, $sort, $filter, $max);
     return $this->cache[$store];
 }
 * @package		GAnalytics
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2013 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_ganalytics' . DS . 'helper' . DS . 'ganalytics.php';
require_once dirname(__FILE__) . DS . 'helper.php';
$profile = ModGAnalyticsStatsCountHelper::getSelectedProfile($params);
if (empty($profile)) {
    return;
}
$startDate = JFactory::getDate($profile->startDate);
$endDate = JFactory::getDate();
$endDate->modify('-1 days');
if ($endDate < $startDate) {
    $endDate = $startDate;
}
$yearData = null;
if ($params->get('selectTotalVisitors', 'yes') == 'yes' || $params->get('selectVisitorsDay', 'yes') == 'yes') {
    $dimensions = array('ga:year');
    $metrics = array('ga:visits');
    $filter = null;
    if ($params->get('pageOnly', 0) == 1) {
        $uri = JFactory::getURI();
        $filter = 'ga:pagePath==' . $uri->getPath() . '?' . $uri->getQuery();
        $dimensions[] = 'ga:pagePath';
    }
    $yearData = GAnalyticsDataHelper::getData($profile, $dimensions, $metrics, $startDate, $endDate, null, $filter, 1000);
}
require JModuleHelper::getLayoutPath('mod_ganalytics_stats_count');
Example #11
0
<?php

/**
 * @package		GAnalytics
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2013 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_ganalytics' . DS . 'libraries' . DS . 'gviz' . DS . 'gviz_api.php';
$data = isset($this->data) ? $this->data : null;
echo GAnalyticsDataHelper::convertToJsonResponse($this->profile, $data, $this->statsView->type);
Example #12
0
<?php

/**
 * @package		GAnalytics
 * @author		Digital Peak http://www.digital-peak.com
 * @copyright	Copyright (C) 2012 - 2015 Digital Peak. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL
 */
defined('_JEXEC') or die;
echo GAnalyticsDataHelper::convertToJsonResponse($this->profile, $this->data, 'image');