You are here

protected function GoogleAnalyticsCounterFeed::sanitizeReport in Google Analytics Counter 7.3

Sanitize report data.

1 call to GoogleAnalyticsCounterFeed::sanitizeReport()
GoogleAnalyticsCounterFeed::queryReportFeed in ./google_analytics_counter_oauth2.lib.inc
Query and sanitize report data.

File

./google_analytics_counter_oauth2.lib.inc, line 475
Provides the Google Analytics Counter Feed object type and associated methods. Most of the Google Analytics authentication process is taken over from http://drupal.org/project/google_analytics_reports because all we need here is its Google Analytics…

Class

GoogleAnalyticsCounterFeed
GoogleAnalyticsCounterFeed class to authorize access to and request data from the Google Analytics Core Reporting API.

Code

protected function sanitizeReport() {

  // Named keys for report values.
  $this->results->rawRows = isset($this->results->rows) ? $this->results->rows : array();
  $this->results->rows = array();
  foreach ($this->results->rawRows as $row_key => $row_value) {
    foreach ($row_value as $item_key => $item_value) {
      $this->results->rows[$row_key][str_replace('ga:', '', $this->results->columnHeaders[$item_key]->name)] = $item_value;
    }
  }
  unset($this->results->rawRows);

  // Named keys for report totals.
  $this->results->rawTotals = $this->results->totalsForAllResults;
  $this->results->totalsForAllResults = array();
  foreach ($this->results->rawTotals as $row_key => $row_value) {
    $this->results->totalsForAllResults[str_replace('ga:', '', $row_key)] = $row_value;
  }
  unset($this->results->rawTotals);
}