Index: googleanalytics.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.admin.inc,v
retrieving revision 1.24.2.28
diff -u -r1.24.2.28 googleanalytics.admin.inc
--- googleanalytics.admin.inc	7 Feb 2011 14:41:11 -0000	1.24.2.28
+++ googleanalytics.admin.inc	9 Feb 2011 21:42:21 -0000
@@ -235,6 +235,24 @@
     '#default_value' => variable_get('googleanalytics_trackadsense', FALSE),
   );
 
+  // Privacy specific configurations.
+  $form['tracking']['privacy'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Privacy'),
+  );
+  $form['tracking']['privacy']['googleanalytics_tracker_anonymizeip'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Anonymize visitors IP address'),
+    '#description' => t('Tell Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting. In some countries it is not allowed to collect personally identifying information for privacy reasons and this setting may help you to comply with the local laws.'),
+    '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
+  );
+  $form['tracking']['privacy']['googleanalytics_privacy_donottrack'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Universal web tracking opt-out'),
+    '#description' => t('If enabled and your server receives the <a href="http://donottrack.us/">Do-Not-Track</a> header from the client browser, the Google Analytics module will not embed any tracking code into your website. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision.'),
+    '#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
+  );
+
   // Backward compatibility only.
   // TODO: If currently not in use, hide the UI and later remove the code.
   $segmentation = variable_get('googleanalytics_segmentation', array());
@@ -341,13 +359,6 @@
     '#collapsed' => TRUE,
   );
 
-  $form['advanced']['googleanalytics_tracker_anonymizeip'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Anonymize visitors IP address'),
-    '#description' => t('Tell Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting. In some countries it is not allowed to collect personally identifying information for privacy reasons and this setting may help you to comply with the local laws.'),
-    '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
-  );
-
   $form['advanced']['googleanalytics_cache'] = array(
     '#type' => 'checkbox',
     '#title' => t('Locally cache tracking code file'),
Index: googleanalytics.admin.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.admin.js,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 googleanalytics.admin.js
--- googleanalytics.admin.js	7 Feb 2011 15:20:57 -0000	1.1.2.7
+++ googleanalytics.admin.js	9 Feb 2011 21:42:21 -0000
@@ -98,6 +98,20 @@
         return Drupal.t('Multiple top-level domains');
       }
     });
+
+    $('fieldset#edit-privacy', context).drupalSetSummary(function (context) {
+      var vals = [];
+      if ($('input#edit-googleanalytics-tracker-anonymizeip', context).is(':checked')) {
+        vals.push('Anonymize IP');
+      }
+      if ($('input#edit-googleanalytics-privacy-donottrack', context).is(':checked')) {
+        vals.push('Universal web tracking opt-out');
+      }
+      if (!vals.length) {
+        return Drupal.t('No privacy');
+      }
+      return Drupal.t('@items enabled', {'@items' : vals.join(', ')});
+    });
   }
 };
 
Index: googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.70.2.13
diff -u -r1.70.2.13 googleanalytics.module
--- googleanalytics.module	7 Feb 2011 17:30:49 -0000	1.70.2.13
+++ googleanalytics.module	9 Feb 2011 21:42:22 -0000
@@ -309,11 +309,25 @@
         break;
     }
 
+    // Disable tracking for visitors who have opted out from tracking via DNT (Do-Not-Track) header.
+    $disabled = FALSE;
+    if (variable_get('googleanalytics_privacy_donottrack', 1) && !empty($_SERVER['HTTP_DNT'])) {
+      $disabled = TRUE;
+
+      // Override settings value.
+      $account->data['googleanalytics']['custom'] = FALSE;
+
+      $description .= '<span class="admin-disabled">';
+      $description .= ' ' . t('You have opted out from tracking via browser privacy settings.');
+      $description .= '</span>';
+    }
+
     $form['googleanalytics']['custom'] = array(
       '#type' => 'checkbox',
       '#title' => t('Enable user tracking'),
       '#description' => $description,
-      '#default_value' => isset($account->data['googleanalytics']['custom']) ? $account->data['googleanalytics']['custom'] : ($custom == 1)
+      '#default_value' => isset($account->data['googleanalytics']['custom']) ? $account->data['googleanalytics']['custom'] : ($custom == 1),
+      '#disabled' => $disabled,
     );
 
     return $form;
@@ -438,8 +452,11 @@
 
   $enabled = FALSE;
 
+  // Disable tracking for visitors who have opted out from tracking via DNT (Do-Not-Track) header.
+  $dnt = (variable_get('googleanalytics_privacy_donottrack', 1) && !empty($_SERVER['HTTP_DNT'])) ? TRUE : FALSE;
+
   // Is current user a member of a role that should be tracked?
-  if (_googleanalytics_visibility_roles($account)) {
+  if (!$dnt && _googleanalytics_visibility_roles($account)) {
 
     // Use the user's block visibility setting, if necessary.
     if (($custom = variable_get('googleanalytics_custom', 0)) != 0) {
