You are here

function analytics_init in Analytics 6

Implementation of hook_init().

File

./analytics.module, line 55
Provides an API for tracking anlytics about your Drupal site.

Code

function analytics_init() {
  global $user;
  if (variable_get('analytics_js_enable', TRUE)) {
    $path = drupal_get_path('module', 'analytics');
    drupal_add_js($path . '/analytics.js', 'module', 'header');
  }
  if (variable_get('analytics_js_settings_enable', FALSE)) {
    $data['analytics'] = array(
      'user_id' => $user->uid,
      'user_name' => $user->name,
      'logged_in' => $user->uid ? TRUE : FALSE,
      'roles' => $user->roles,
    );
    drupal_add_js($data, 'setting', 'header');
  }
}