Skip to content

Commit b3adf43

Browse files
committed
Add Configuration option to disable Back Office tracking
1 parent 5debadb commit b3adf43

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

classes/Form/ConfigurationForm.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ public function generate()
127127
],
128128
],
129129
],
130+
[
131+
'type' => 'switch',
132+
'label' => $this->module->l('Disable Back Office Tracking'),
133+
'name' => 'GA_TRACK_BACKOFFICE_DISABLED',
134+
'hint' => $this->module->l('Use this option to disable the tracking inside the Back Office'),
135+
'values' => [
136+
[
137+
'id' => 'ga_track_backoffice',
138+
'value' => 1,
139+
'label' => $this->module->l('Enabled'),
140+
],
141+
[
142+
'id' => 'ga_do_not_track_backoffice',
143+
'value' => 0,
144+
'label' => $this->module->l('Disabled'),
145+
],
146+
],
147+
],
130148
],
131149
'submit' => [
132150
'title' => $this->module->l('Save'),
@@ -158,6 +176,7 @@ public function generate()
158176
$helper->fields_value['GA_USERID_ENABLED'] = Configuration::get('GA_USERID_ENABLED');
159177
$helper->fields_value['GA_CROSSDOMAIN_ENABLED'] = Configuration::get('GA_CROSSDOMAIN_ENABLED');
160178
$helper->fields_value['GA_ANONYMIZE_ENABLED'] = Configuration::get('GA_ANONYMIZE_ENABLED');
179+
$helper->fields_value['GA_TRACK_BACKOFFICE_DISABLED'] = Configuration::get('GA_TRACK_BACKOFFICE_DISABLED');
161180

162181
return $helper->generateForm($fields_form);
163182
}
@@ -174,6 +193,7 @@ public function treat()
174193
$gaUserIdEnabled = Tools::getValue('GA_USERID_ENABLED');
175194
$gaCrossdomainEnabled = Tools::getValue('GA_CROSSDOMAIN_ENABLED');
176195
$gaAnonymizeEnabled = Tools::getValue('GA_ANONYMIZE_ENABLED');
196+
$gaTrackBackOffice = Tools::getValue('GA_TRACK_BACKOFFICE_DISABLED');
177197

178198
if (!empty($gaAccountId)) {
179199
Configuration::updateValue('GA_ACCOUNT_ID', $gaAccountId);
@@ -196,6 +216,11 @@ public function treat()
196216
$treatmentResult .= $this->module->displayConfirmation($this->module->l('Settings for Anonymize IP updated successfully'));
197217
}
198218

219+
if (null !== $gaTrackBackOffice) {
220+
Configuration::updateValue('GA_TRACK_BACKOFFICE_DISABLED', (bool) $gaTrackBackOffice);
221+
$treatmentResult .= $this->module->displayConfirmation($this->module->l('Settings for Disable Back Office tracking updated successfully'));
222+
}
223+
199224
return $treatmentResult;
200225
}
201226
}

classes/Hook/HookDisplayBackOfficeHeader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function __construct(Ps_Googleanalytics $module, Context $context)
4848
*/
4949
public function run()
5050
{
51+
if (Configuration::get('GA_TRACK_BACKOFFICE_DISABLED')) {
52+
return;
53+
}
54+
5155
$js = '';
5256
if (strcmp(Tools::getValue('configure'), $this->module->name) === 0) {
5357
$this->context->controller->addCSS($this->module->getPathUri() . 'views/css/ganalytics.css');

classes/Hook/HookDisplayHeader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function run()
5050
return;
5151
}
5252

53+
if (Configuration::get('GA_TRACK_BACKOFFICE_DISABLED') && $this->backOffice) {
54+
return;
55+
}
56+
5357
$this->context->controller->addJs($this->module->getPathUri() . 'views/js/GoogleAnalyticActionLib.js');
5458

5559
$shops = Shop::getShops();

0 commit comments

Comments
 (0)