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	30 Sep 2010 11:45:02 -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 = '';
+  // Initialise scripts for Google Analytics versions 2.x and 3.x.
+  $script2 = 'try{';
+  $script3 = 'try{';
 
   // 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,17 @@ 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;
+  // Finalize scripts.
+  $script2 .= '} catch(err) {}';
+  $script3 .= '} catch(err) {}';
+
+  return $script2 . "\n" . $script3;
 }
