commit a8fa55d32e994c2675b4b3648b6acc64554baf04
Author: Brückner Tamás <tamas.bruckner@integralvision.hu>
Date:   Tue Feb 24 12:36:14 2015 +0100

    Exlude bots from statistics.

diff --git a/modules/statistics/statistics.admin.inc b/modules/statistics/statistics.admin.inc
index e83a115..16e6d16 100644
--- a/modules/statistics/statistics.admin.inc
+++ b/modules/statistics/statistics.admin.inc
@@ -315,6 +315,13 @@ function statistics_settings_form() {
       ),
     ),
   );
+  $form['content']['statistics_count_content_views_exclude_bots'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Exclude bots'),
+    '#default_value' => variable_get('statistics_count_content_views_exclude_bots', 0),
+    '#description' => t('Exclude search engine and other bots from statistics.'),
+  );
+
 
   return system_settings_form($form);
 }
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index f665a14..9bf9335 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -57,7 +57,20 @@ function statistics_exit() {
   // in which case we need to bootstrap to the session phase anyway.
   drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
 
-  if (variable_get('statistics_count_content_views', 0) && !variable_get('statistics_count_content_views_ajax', 0)) {
+  $check_bot = TRUE;
+  if (
+    variable_get('statistics_count_content_views_exclude_bots', 0)
+    && isset($_SERVER['HTTP_USER_AGENT'])
+    && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])
+  ) {
+    $check_bot = FALSE;
+  }
+
+  if (
+    $check_bot
+    && variable_get('statistics_count_content_views', 0)
+    && !variable_get('statistics_count_content_views_ajax', 0)
+  ) {
     // We are counting content views.
     if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
       // A node has been viewed, so update the node's counters.
