function ga_stats_ga_data in Google Analytics Statistics 7.x
Same name and namespace in other branches
- 7.2 includes/ga.inc \ga_stats_ga_data()
- 7 includes/ga.inc \ga_stats_ga_data()
call back funciton for pulling data from google anaylics
Parameters
metrics_in : and array or string of the metrics to pull: @param start_date : time as an int @param end_date : time as an int @return : and array of external_statistics_count db obj
1 call to ga_stats_ga_data()
- ga_stats_get_data in ./
ga_stats.module - pull data from a source
File
- inc/
ga.inc, line 11
Code
function ga_stats_ga_data($metrics, $start_date = 0, $end_date = 0, $filter = false) {
$url_dim = 'pagePath';
if (!is_array($metrics)) {
$metrics = array(
$metrics,
);
}
$request['dimensions'] = array(
$url_dim,
);
$request['metrics'] = $metrics;
if ($start_date) {
$request['start_date'] = date('Y-m-d', $start_date);
}
else {
$request['start_date'] = null;
}
if ($end_date) {
$request['end_date'] = date('Y-m-d', $end_date);
}
else {
$request['end_date'] = null;
}
$request['sort_metric'] = "-" . $metrics[0];
$request['max_results'] = variable_get('ga_stats_max_results', "100");
if ($filter) {
$request['filter'] = $filter;
}
$data_raw = ga_stats_query_data($request);
$data_array = ga_stats_ga_data_array($data_raw);
foreach ($data_array as $k => $d) {
$data_array[$k]['url'] = $d[$url_dim];
}
return $data_array;
}