function ga_stats_get_data in Google Analytics Statistics 7.x
pull data from a source
Parameters
$source_name : then name of the source from which to pull data:
$metrics : an array or string of the metrics to pull:
$time_frame : a time_frame obj :
$end_time : the end time from which data is pulled:
Return value
: an array of obj ready for the ga_stats_count table
1 call to ga_stats_get_data()
File
- ./
ga_stats.module, line 13
Code
function ga_stats_get_data($metric, $start_time, $end_time, $timeframe = '') {
$data_array = ga_stats_ga_data($metric, $start_time, $end_time);
$metrics = ga_stats_ga_metrics();
$counts = array();
foreach ($data_array as $d) {
$count = new stdClass();
$count->url = $d['url'];
$count->count = $d[$metric];
$count->metric = $metric;
$count->nid = false;
$count->timeframe = $timeframe;
$alias = preg_replace('/^\\//', '', $count->url);
if (!preg_match('/^node\\/([0-9]*)/', $alias, $matches)) {
$alias = drupal_lookup_path('source', $alias);
}
if (preg_match('/^node\\/([0-9]*)/', $alias, $matches)) {
$count->nid = $matches[1];
}
// only log nodes
if ($count->nid) {
$counts[] = $count;
}
}
return $counts;
}