Index: googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.65
diff -u -r1.65 googleanalytics.module
--- googleanalytics.module	20 Oct 2010 23:36:45 -0000	1.65
+++ googleanalytics.module	23 Oct 2010 15:20:50 -0000
@@ -51,9 +51,9 @@
 }
 
 /**
- * Implementation of hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
+ * Implementation of hook_page_build() to insert JavaScript to the appropriate scope/region of the page.
  */
-function googleanalytics_page_alter(&$page) {
+function googleanalytics_page_build(&$page) {
   global $user;
 
   $id = variable_get('googleanalytics_account', '');
@@ -74,13 +74,9 @@
     // We allow different scopes. Default to 'header' but allow user to override if they really need to.
     $scope = variable_get('googleanalytics_js_scope', 'header');
 
-    // Custom tracking. Prepend before all other JavaScript.
     if (variable_get('googleanalytics_trackadsense', FALSE)) {
-      $page['footer']['googleanalytics']['#attached']['js']['window.google_analytics_uacct = ' . drupal_json_encode($id) . ';'] = array(
-        'type' => 'inline',
-        'scope' => 'header',
-        'weight' => JS_LIBRARY - 21,
-      );
+      // Custom tracking. Prepend before all other JavaScript.
+      drupal_add_js('window.google_analytics_uacct = ' . drupal_json_encode($id) . ';', array('type' => 'inline', 'weight' => JS_LIBRARY - 21));
     }
 
     // Add link tracking.
@@ -96,11 +92,8 @@
       $link_settings['trackDownloadExtensions'] = $trackfiles_extensions;
     }
     if (!empty($link_settings)) {
-      $page['footer']['googleanalytics']['#attached']['js'][] = array(
-        'type' => 'setting',
-        'data' => array('googleanalytics' => $link_settings),
-      );
-      $page['footer']['googleanalytics']['#attached']['js'][drupal_get_path('module', 'googleanalytics') .'/googleanalytics.js'] = array('scope' => $scope);
+      drupal_add_js(array('googleanalytics' => $link_settings), 'setting');
+      drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.js');
     }
 
     // Add User profile segmentation values.
@@ -201,11 +194,7 @@
     $script .= 's.parentNode.insertBefore(ga, s);';
     $script .= '})();';
 
-    // Add tracker code to scope.
-    $page['footer']['googleanalytics']['#attached']['js'][$script] = array(
-      'type' => 'inline',
-      'scope' => $scope,
-    );
+    drupal_add_js($script, array('scope'=> $scope, 'type' => 'inline'));
   }
 }
 
