You are here

function googleanalytics_cron in Google Analytics 6.3

Same name and namespace in other branches
  1. 5 googleanalytics.module \googleanalytics_cron()
  2. 6.4 googleanalytics.module \googleanalytics_cron()
  3. 6 googleanalytics.module \googleanalytics_cron()
  4. 6.2 googleanalytics.module \googleanalytics_cron()
  5. 7.2 googleanalytics.module \googleanalytics_cron()
  6. 7 googleanalytics.module \googleanalytics_cron()

Implementation of hook_cron().

File

./googleanalytics.module, line 343
Drupal Module: GoogleAnalytics Adds the required Javascript to the bottom of all your Drupal pages to allow tracking by the Google Analytics statistics package.

Code

function googleanalytics_cron() {

  // Regenerate the tracking code file every day.
  if (time() - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {

    // Which version of the tracking library should be used?
    if (variable_get('googleanalytics_trackdoubleclick', FALSE)) {
      _googleanalytics_cache('http://stats.g.doubleclick.net/dc.js', TRUE);
    }
    else {
      _googleanalytics_cache('http://www.google-analytics.com/ga.js', TRUE);
    }
    variable_set('googleanalytics_last_cache', time());
  }
}