Index: googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.48
diff -u -r1.48 googleanalytics.module
--- googleanalytics.module	28 Aug 2010 15:30:53 -0000	1.48
+++ googleanalytics.module	30 Sep 2010 00:03:06 -0000
@@ -185,8 +185,8 @@
     $script .= 'ga.async = true;';
 
     // Should a local cached copy of ga.js be used?
-    if (variable_get('googleanalytics_cache', 0) && $source = _googleanalytics_cache('http://www.google-analytics.com/ga.js')) {
-      $script .= 'ga.src = "' . file_create_url($source) . '";';
+    if (variable_get('googleanalytics_cache', 0) && $path = _googleanalytics_cache('http://www.google-analytics.com/ga.js')) {
+      $script .= 'ga.src = "' . $path . '";';
     }
     else {
       $script .= 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";';
@@ -268,6 +268,12 @@
  *   The path to the local javascript file on success, boolean FALSE on failure.
  */
 function _googleanalytics_cache($location) {
+  // A dummy query-string is added to filenames, to gain control over
+  // browser-caching. The string changes on every update or full cache
+  // flush, forcing browsers to load a new copy of the files, as the
+  // URL changed.
+  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
+
   $path = 'public://googleanalytics';
   $file_destination = $path .'/'. basename($location);
   if (!file_exists($file_destination)) {
@@ -275,12 +281,12 @@
     if ($result->code == 200) {
       // Check that the files directory is writable
       if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
-        return file_unmanaged_save_data($result->data, $path .'/'. basename($location), FILE_EXISTS_REPLACE);
+        return base_path() . file_unmanaged_save_data($result->data, $path .'/'. basename($location), FILE_EXISTS_REPLACE) . $query_string;
       }
     }
   }
   else {
-    return $file_destination;
+    return base_path() . $file_destination . $query_string;
   }
 }
 
