function ga_stats_transform_data in Google Analytics Statistics 7
Same name and namespace in other branches
- 7.2 includes/ga.inc \ga_stats_transform_data()
 
Transform data from the retrieved structure to one ready for Drupal storage.
Parameters
array $results: Set of results retrieved from GA.
array|string $metric: An array or string of the metrics to pull.
$timeframe: Identifier for a predetermine timeframe.
Return value
array An array of obj ready for the ga_stats_count table
1 call to ga_stats_transform_data()
- ga_stats_collect_data in includes/
ga.inc  - Retrieve data for all configured metrics and time-frames.
 
File
- includes/
ga.inc, line 70  
Code
function ga_stats_transform_data($results, $metric, $timeframe = '') {
  $data = array();
  foreach ($results as $record) {
    $item = new stdClass();
    $item->url = $record['url'];
    $item->count = $record[$metric];
    $item->metric = $metric;
    $item->nid = FALSE;
    $item->timeframe = $timeframe;
    $item->nid = ga_stats_nid_from_url($record['url']);
    // Only log nodes.
    if ($item->nid) {
      $data[] = $item;
    }
  }
  return $data;
}