? 324764_google_analytics_multiple_accounts.patch
Index: googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.19.2.6
diff -u -p -r1.19.2.6 googleanalytics.module
--- googleanalytics.module	13 Oct 2008 21:48:49 -0000	1.19.2.6
+++ googleanalytics.module	22 Oct 2008 21:42:39 -0000
@@ -109,7 +109,7 @@ function googleanalytics_footer($main = 
       // Only show segmentation variable if there are specified fields.
       $segmentation = '';
       if (count($fields) > 0) {
-        $segmentation = 'pageTracker._setVar('. drupal_to_js(implode(':', $fields)) .');';
+        $segmentation = drupal_to_js(implode(':', $fields)) .');';
       }
     }
 
@@ -149,18 +149,25 @@ function googleanalytics_footer($main = 
     $codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
 
     // Build tracker code for footer.
-    $script = 'var pageTracker = _gat._getTracker('. drupal_to_js($id) .');';
-    if (!empty($segmentation)) {
-      $script .= $segmentation;
-    }
-    if (!empty($codesnippet_before)) {
-      $script .= $codesnippet_before;
-    }
-    $script .= 'pageTracker._trackPageview('. $url_custom .');';
-    if (!empty($codesnippet_after)) {
-      $script .= $codesnippet_after;
-    }
+    $ids = module_invoke_all('google_analytics_get_tracker');
+    $ids[] = $id;
 
+    $i = 1;
+    $script = '';
+    foreach ($ids as $id) {
+      $script .= 'var pageTracker'. $i .'= _gat._getTracker('. drupal_to_js($id) .');';
+      if (!empty($segmentation)) {
+        $script .= 'pageTracker'. $i .'._setVar('. $segmentation;
+      }
+      if (!empty($codesnippet_before)) {
+        $script .= $codesnippet_before;
+      }
+      $script .= 'pageTracker'. $i .'._trackPageview('. $url_custom .');';
+      if (!empty($codesnippet_after)) {
+        $script .= $codesnippet_after;
+      }
+      $i++;
+    }
     drupal_add_js($script, 'inline', 'footer');
   }
 }
