Index: googleanalytics.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v retrieving revision 1.44 diff -u -r1.44 googleanalytics.module --- googleanalytics.module 6 Jun 2010 11:10:19 -0000 1.44 +++ googleanalytics.module 7 Jun 2010 17:39:51 -0000 @@ -58,10 +58,18 @@ $id = variable_get('googleanalytics_account', ''); + // Get page status code for visibility filtering. + $status = drupal_get_http_header('Status'); + $trackable_status_codes = array( + '403 Forbidden', + '404 Not Found', + } + // 1. Check if the GA account number has a value. // 2. Track page views based on visibility value. // 3. Check if we should track the currently active user's role. - if (!empty($id) && _googleanalytics_visibility_pages() && _googleanalytics_visibility_user($user)) { + // 4. Ignore visibility filters for 404 or 403 status codes. + if (!empty($id) && (_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) { // We allow different scopes. Default to 'footer' but allow user to override if they really need to. $scope = variable_get('googleanalytics_js_scope', 'header'); @@ -135,7 +143,6 @@ } // Track access denied (403) and file not found (404) pages. - $status = drupal_get_http_header('Status'); if ($status == '403 Forbidden') { // See http://www.google.com/support/analytics/bin/answer.py?answer=86927 $url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';