Ejemplo n.º 1
0
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $obj = Analytics::instance();
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:visits', ['dimensions' => 'ga:browser', 'sort' => '-ga:visits']);
     $this->vars['rows'] = $data->getRows();
 }
Ejemplo n.º 2
0
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $obj = Analytics::instance();
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:visits', ['dimensions' => 'ga:source', 'sort' => '-ga:visits']);
     $rows = $data->getRows() ?: [];
     $this->vars['rows'] = array_slice($rows, 0, $this->property('number'));
     $this->vars['total'] = $data->getTotalsForAllResults()['ga:visits'];
 }
Ejemplo n.º 3
0
 /**
  * Loads the analytics data
  */
 protected function loadData()
 {
     if (!($days = $this->property('days'))) {
         throw new ApplicationException(trans('bedard.analyticsextension::lang.errors.invalid_days') . $days);
     }
     if (!($dimension = $this->property('dimension'))) {
         throw new ApplicationException(trans('bedard.analyticsextension::lang.errors.invalid_dimension') . $dimension);
     }
     if (!($metric = $this->property('metric'))) {
         throw new ApplicationException(trans('bedard.analyticsextension::lang.errors.invalid_metric') . $metric);
     }
     $obj = Analytics::instance();
     return $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', $metric, ['dimensions' => $dimension, 'sort' => '-' . $metric]);
 }
Ejemplo n.º 4
0
 /**
  * Loads the analytics data
  */
 protected function loadData()
 {
     if (!($days = $this->property('days'))) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     if (!($dimension = $this->property('dimension'))) {
         throw new ApplicationException('Invalid dimension value: ' . $dimension);
     }
     if (!($metric = $this->property('metric'))) {
         throw new ApplicationException('Invalid metric value: ' . $metric);
     }
     $obj = Analytics::instance();
     return $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', $metric, ['dimensions' => $dimension, 'sort' => '-' . $metric]);
 }
Ejemplo n.º 5
0
 protected function loadData()
 {
     $obj = Analytics::instance();
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:visits', ['dimensions' => 'ga:date']);
     $points = [];
     foreach ($data->getRows() as $row) {
         $point = [strtotime($row[0]) * 1000, $row[1]];
         $points[] = $point;
     }
     $this->vars['rows'] = str_replace('"', '', substr(substr(json_encode($points), 1), 0, -1));
 }
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $goal = $this->property('goal');
     if (!$goal) {
         throw new ApplicationException('Invalid goal value: ' . $goal);
     }
     $obj = Analytics::instance();
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:visits')->getRows();
     $total = $this->vars['total'] = isset($data[0][0]) ? $data[0][0] : 0;
     $this->vars['percentage'] = min(round($total / $goal * 100), 100);
 }
Ejemplo n.º 7
0
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $obj = Analytics::instance();
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:pageviews', ['dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews']);
     $rows = $data->getRows() ?: [];
     $rows = $this->vars['rows'] = array_slice($rows, 0, $this->property('number'));
     $total = 0;
     foreach ($rows as $row) {
         $total += $row[1];
     }
     $this->vars['total'] = $total;
 }
Ejemplo n.º 8
0
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     $this->createFilter();
     $obj = Analytics::instance();
     $data = $obj->service->data_ga->get($obj->viewId, $days . 'daysAgo', 'today', 'ga:totalEvents', ['dimensions' => 'ga:eventCategory, ga:eventAction, ga:eventLabel', 'sort' => '-ga:totalEvents', 'filters' => $this->filter, 'max-results' => $this->property('number', 10)]);
     $rows = $data->getRows() ?: [];
     $this->vars['rows'] = $rows;
     $total = 0;
     foreach ($rows as $row) {
         $total += $row[3];
     }
     $this->vars['total'] = $total;
 }