The option to cache urchin.js locally has a few problems.

1. For sites that run cron more than once per day, the local cache file is never updated.

function googleanalytics_cron() {
  // Regenerate the google analytics urchin.js every day.
  if (time() - variable_get('cron_last', 0) >= 86400) {
    file_delete(file_directory_path() .'/googleanalytics/urchin.js');
  }
}

The if statement is always false if cron runs more than once per day. It should be:

  function googleanalytics_cron() {
    // Regenerate the google analytics urchin.js every day.
!   if (time() - variable_get('googleanalytics_last_cache', 0) >= 86400) {
      file_delete(file_directory_path() .'/googleanalytics/urchin.js');
+     variable_set('googleanalytics_last_cache', time());
    }
  }
 

2. If local caching is enabled, downloadtracker.js is also linked from the cache but it is never downloaded (and never cleaned from the cache).

Comments

rconstantine’s picture

What do you mean in #2? I agree with your results in #1.

I think in #2 you're saying that if you look at the generated source that the js file linked to is in the files directory with the urchin.js file. If so, I'm not seeing that. I see that the downloadtracker.js file is linked to from the module file thus: /sites/all/modules/google_analytics/downloadtracker.js

I do have caching enabled.

hass’s picture

Status: Active » Fixed

#1: Fixed in D5 and D6 branch
#2: downloadtracker.js is not cached... reopen if an issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.