function google_analytics_et_init in Google Analytics Event Tracking 6
Implements hook_init().
File
- ./
google_analytics_et.module, line 14 - Google Analytics Event Tracking Module.
Code
function google_analytics_et_init() {
global $user;
$id = variable_get('googleanalytics_account', '');
// Get page status code for visibility filtering.
//$status = drupal_get_http_header('Status');
$trackable_status_codes = array(
'403 Forbidden',
'404 Not Found',
);
// Get all selectors defined by google_analytics_et_api hook.
$selectors = module_invoke_all('google_analytics_et_api');
// If the override selectors toggle is TRUE then only load the selectors
// from the variable table.
$override_hooked_selectors = variable_get('google_analytics_et_selectors_override', FALSE);
if ($override_hooked_selectors) {
$selectors = variable_get('google_analytics_et_selectors', '');
}
// Sanitize event tracking input to limit the threat of xss.
$selectors = _google_analytics_et_sanitize_event_trackers($selectors);
$js = array(
'googleAnalyticsETSettings' => array(
'selectors' => $selectors,
),
);
//if (!empty($id) && (_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
if (!empty($id) && _googleanalytics_visibility_pages() && _googleanalytics_visibility_user($user)) {
// Get the page scope setting from googleanalytics:
$scope = variable_get('googleanalytics_js_scope', 'header');
drupal_add_js($js, 'setting');
drupal_add_js(drupal_get_path('module', 'google_analytics_et') . '/js/google_analytics_et.js', 'module', $scope);
}
}