Index: uc_googleanalytics/uc_googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_googleanalytics/uc_googleanalytics.module,v
retrieving revision 1.6.2.9
diff -u -p -r1.6.2.9 uc_googleanalytics.module
--- uc_googleanalytics/uc_googleanalytics.module	12 Jul 2010 01:31:31 -0000	1.6.2.9
+++ uc_googleanalytics/uc_googleanalytics.module	5 Oct 2010 11:38:53 -0000
@@ -93,7 +93,9 @@ function uc_googleanalytics_display() {
  *   The JS that should be added to the page footer.
  */
 function uc_googleanalytics_ecommerce_js($order) {
-  $script = '';
+  // Support both Google Analytics versions 2.x and 3.x.
+  $script2 = '';
+  $script3 = '';
 
   // Lookup the name of the country or default to the ID if it can't be found
   // for some reason.
@@ -148,7 +150,8 @@ function uc_googleanalytics_ecommerce_js
   );
 
   // Add the transaction line to the JS.
-  $script .= 'pageTracker._addTrans('. implode(', ', $args) .');';
+  $script2 .= 'pageTracker._addTrans('. implode(', ', $args) .');';
+  $script3 .= '_gaq.push(["_addTrans", '. implode(', ', $args) .']);';
 
   // Loop through the products on the order.
   foreach ($order->products as $product) {
@@ -191,11 +194,15 @@ function uc_googleanalytics_ecommerce_js
     );
 
     // Add the item line to the JS.
-    $script .= 'pageTracker._addItem('. implode(', ', $args) .');';
+    $script2 .= 'pageTracker._addItem('. implode(', ', $args) .');';
+    $script3 .= '_gaq.push(["_addItem", '. implode(', ', $args) .']);';
   }
 
   // Add the function to submit the transaction to GA.
-  $script .= 'pageTracker._trackTrans();';
+  $script2 .= 'pageTracker._trackTrans();';
+  $script3 .= '_gaq.push(["_trackTrans"]);';
 
-  return $script;
+  // Google Analytics 3.x starts with schema version 6300.
+  $version = db_result(db_query("SELECT schema_version FROM {system} WHERE type = 'module' AND name = 'googleanalytics'"));
+  return $version >= 6300 ? $script3 : $script2;
 }
