function google_analytics_reports_api_report_data in Google Analytics Reports 7.3
Same name and namespace in other branches
- 8.3 google_analytics_reports_api/google_analytics_reports_api.module \google_analytics_reports_api_report_data()
Request report data.
Parameters
array $params: An associative array containing:
- profile_id: required [default=variable_get('google_analytics_reports_api_profile_id')].
- metrics: required.
- dimensions: optional [default=none].
- sort_metric: optional [default=none].
- filters: optional [default=none].
- segment: optional [default=none].
- start_date: optional [default=2005-01-01].
- end_date: optional [default=today].
- start_index: optional [default=1].
- max_results: optional [default=10,000].
array $cache_options: An optional associative array containing:
- cid: optional [default=md5 hash].
- expire: optional [default=CACHE_TEMPORARY].
- refresh: optional [default=FALSE].
Return value
object GoogleAnalyticsReportsApiFeed object to authorize access and request data from the Google Analytics Core Reporting API after reporting data.
1 call to google_analytics_reports_api_report_data()
- google_analytics_reports_plugin_query_google_analytics::execute in plugins/
google_analytics_reports_plugin_query_google_analytics.inc - Executes the query and fills the associated view object with according values.
File
- google_analytics_reports_api/
google_analytics_reports_api.module, line 155 - Implements the API through which Google Analytics data can be accessed.
Code
function google_analytics_reports_api_report_data($params = array(), $cache_options = array()) {
if (isset($params['profile_id'])) {
$params['profile_id'] = 'ga:' . $params['profile_id'];
}
else {
$params['profile_id'] = 'ga:' . variable_get('google_analytics_reports_api_profile_id', 0);
}
$ga_feed = google_analytics_reports_api_gafeed();
if ($ga_feed) {
$ga_feed
->queryReportFeed($params, $cache_options);
return $ga_feed;
}
else {
drupal_set_message(t('There was an authentication error. Please check your Google Analytics API settings and try again.'), 'error', FALSE);
watchdog('google analytics reports api', 'There was an authentication error. Please check your Google Analytics API settings and try again.', array(), WATCHDOG_ERROR);
return array(
'error' => TRUE,
);
}
}