Index: googleanalytics.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.admin.inc,v
retrieving revision 1.18
diff -u -r1.18 googleanalytics.admin.inc
--- googleanalytics.admin.inc	5 Jun 2010 01:36:21 -0000	1.18
+++ googleanalytics.admin.inc	6 Jun 2010 00:14:35 -0000
@@ -202,6 +202,13 @@
     '#collapsed' => TRUE,
   );
 
+  $form['advanced']['googleanalytics_tracker_anonymizeip'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Anonymize visitors IP address'),
+    '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
+    '#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.'),
+  );
+
   $form['advanced']['googleanalytics_cache'] = array(
     '#type' => 'checkbox',
     '#title' => t('Locally cache tracking code file'),
Index: googleanalytics.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.install,v
retrieving revision 1.16
diff -u -r1.16 googleanalytics.install
--- googleanalytics.install	6 Jun 2010 00:08:31 -0000	1.16
+++ googleanalytics.install	6 Jun 2010 00:14:35 -0000
@@ -18,6 +18,15 @@
     'node/*/*',
   );
   variable_set('googleanalytics_pages', implode("\n", $pages));
+
+  // By German law it's always best to enable the anonymizing of IP addresses.
+  // If this also is an important default setting in other countries, please let us know!
+  $countries = array(
+    'DE',
+  );
+  if (in_array(variable_get('site_default_country', ''), $countries)) {
+    variable_set('googleanalytics_tracker_anonymizeip', 1);
+  }
 }
 
 function googleanalytics_uninstall() {
@@ -38,6 +47,7 @@
   variable_del('googleanalytics_roles');
   variable_del('googleanalytics_visibility');
   variable_del('googleanalytics_pages');
+  variable_del('googleanalytics_tracker_anonymizeip');
   variable_del('googleanalytics_translation_set');
 }
 
@@ -261,3 +271,17 @@
 
   return t('Google tracking code has been moved to header.');
 }
+
+/**
+ * Automatically enable anonymizing of IP addresses for Germany.
+ */
+function googleanalytics_update_7001() {
+  // By German law it's always best to enable the anonymizing of IP addresses.
+  $countries = array(
+    'DE',
+  );
+  if (in_array(variable_get('site_default_country', ''), $countries)) {
+    variable_set('googleanalytics_tracker_anonymizeip', 1);
+    return t('Site is located in Germany -> Anonymizing of IP addresses has been enabled.');
+  }
+}
Index: googleanalytics.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_analytics/googleanalytics.module,v
retrieving revision 1.43
diff -u -r1.43 googleanalytics.module
--- googleanalytics.module	3 Jun 2010 23:44:23 -0000	1.43
+++ googleanalytics.module	6 Jun 2010 00:14:35 -0000
@@ -151,6 +151,9 @@
     // Build tracker code.
     $script = 'var _gaq = _gaq || [];';
     $script .= '_gaq.push(["_setAccount", ' . drupal_json_encode($id) . ']);';
+    if (variable_get('googleanalytics_tracker_anonymizeip', 0)) {
+      $script .= '_gaq.push(["_anonymizeIp"]);';
+    }
     if (!empty($segmentation)) {
       $script .= $segmentation;
     }
