From 87bbf0485c5b7e95ba89484769dfe263f8f74d8d Mon Sep 17 00:00:00 2001 From: br Date: Thu, 3 Dec 2015 15:53:31 +0100 Subject: [PATCH] [*] MO: ganalytics anonymizeIp feature added as selectable option --- ganalytics.php | 31 +++++++++++++++++++++++++++++++ upgrade/Upgrade-2.3.4.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 upgrade/Upgrade-2.3.4.php diff --git a/ganalytics.php b/ganalytics.php index 1e56d7a..f5431c6 100755 --- a/ganalytics.php +++ b/ganalytics.php @@ -197,6 +197,24 @@ public function displayForm() ), ), ), + array( + 'type' => 'radio', + 'label' => $this->l('Enable AnonymizeIp'), + 'name' => 'GA_ANONYMIZEIP_ENABLED', + 'hint' => $this->l('If enabled, prevents Google from saving the full IP address for a visitor.'), + 'values' => array( + array( + 'id' => 'ga_anonymizeip_enabled', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'ga_anonymizeip_disabled', + 'value' => 0, + 'label' => $this->l('Disabled') + ), + ), + ), ), 'submit' => array( 'title' => $this->l('Save'), @@ -206,6 +224,7 @@ public function displayForm() // Load current value $helper->fields_value['GA_ACCOUNT_ID'] = Configuration::get('GA_ACCOUNT_ID'); $helper->fields_value['GA_USERID_ENABLED'] = Configuration::get('GA_USERID_ENABLED'); + $helper->fields_value['GA_ANONYMIZEIP_ENABLED'] = Configuration::get('GA_ANONYMIZEIP_ENABLED'); return $helper->generateForm($fields_form); } @@ -231,6 +250,12 @@ public function getContent() Configuration::updateValue('GA_USERID_ENABLED', (bool)$ga_userid_enabled); $output .= $this->displayConfirmation($this->l('Settings for User ID updated successfully')); } + $ga_anonymizeip_enabled = Tools::getValue('GA_ANONYMIZEIP_ENABLED'); + if (null !== $ga_anonymizeip_enabled) + { + Configuration::updateValue('GA_ANONYMIZEIP_ENABLED', (bool)$ga_anonymizeip_enabled); + $output .= $this->displayConfirmation($this->l('Settings for AnonymizeIp updated successfully')); + } } if (version_compare(_PS_VERSION_, '1.5', '>=')) @@ -249,12 +274,17 @@ public function getContent() protected function _getGoogleAnalyticsTag($back_office = false) { $user_id = null; + $anonymizeip = false; if (Configuration::get('GA_USERID_ENABLED') && $this->context->customer && $this->context->customer->isLogged() ){ $user_id = (int)$this->context->customer->id; } + if (Configuration::get('GA_ANONYMIZEIP_ENABLED')) { + $anonymizeip = true; + } + return ' '; } diff --git a/upgrade/Upgrade-2.3.4.php b/upgrade/Upgrade-2.3.4.php new file mode 100644 index 0000000..e28214b --- /dev/null +++ b/upgrade/Upgrade-2.3.4.php @@ -0,0 +1,32 @@ + +* @copyright 2007-2015 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ +if (!defined('_PS_VERSION_')) + exit; +function upgrade_module_2_3_4($object) +{ + Configuration::updateValue('GA_ANONYMIZEIP_ENABLED', false); + return true; +}