diff --git a/Template/Tag/MatomoTag.web.js b/Template/Tag/MatomoTag.web.js index 15d0a548..68de1ee0 100644 --- a/Template/Tag/MatomoTag.web.js +++ b/Template/Tag/MatomoTag.web.js @@ -126,6 +126,10 @@ tracker.disableBrowserFeatureDetection(); } + if (matomoConfig.requireConsentForCampaignTracking) { + tracker.disableCampaignParameters(); + } + if (matomoConfig.disableCookies) { tracker.disableCookies(); } diff --git a/Template/Variable/MatomoConfigurationVariable.php b/Template/Variable/MatomoConfigurationVariable.php index a6ffdac6..13e90528 100644 --- a/Template/Variable/MatomoConfigurationVariable.php +++ b/Template/Variable/MatomoConfigurationVariable.php @@ -227,6 +227,10 @@ public function getParameters() $field->inlineHelp = Piwik::translate('TagManager_MatomoConfigurationMatomoDisableBrowserFeatureDetectionInLineHelp', ['
', '', '', '']); }), + $this->makeSetting('requireConsentForCampaignTracking', false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { + $field->title = Piwik::translate('TagManager_MatomoConfigurationMatomoRequireConsentForCampaignTrackingTitle'); + $field->description = Piwik::translate('TagManager_MatomoConfigurationMatomoRequireConsentForCampaignTrackingDescription'); + }), $this->makeSetting('domains', array(), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) { $field->title = Piwik::translate('TagManager_MatomoConfigurationMatomoDomainsTitle'); $field->description = Piwik::translate('TagManager_MatomoConfigurationMatomoDomainsDescription'); diff --git a/lang/en.json b/lang/en.json index 7280231c..3adb7108 100644 --- a/lang/en.json +++ b/lang/en.json @@ -622,6 +622,8 @@ "MatomoConfigurationMatomoRequestMethodInlineHelp": "To use the POST request method, either 1) the Matomo host is the same as the tracked website host (Matomo installed in the same domain as your tracked website), or 2) if Matomo is not installed on the same host as your website, you need to enable CORS (Cross domain requests) as explained in this %1$sFAQ%2$s. Keep in mind that when Matomo uses sendBeacon() for sending tracking requests (which is enabled by default), it will send data via POST. If you want Matomo to never send POST requests, you can use this method to force GET which will automatically disable sendBeacon.%3$s", "MatomoConfigurationMatomoRequestContentTypeTitle": "Content-Type", "MatomoConfigurationMatomoRequestContentTypeDescription": "Set request Content-Type header value for POST requests.", + "MatomoConfigurationMatomoRequireConsentForCampaignTrackingTitle": "Require consent to track campaign parameters", + "MatomoConfigurationMatomoRequireConsentForCampaignTrackingDescription": "By enabling the consent requirement, Matomo will track campaign parameters only for users who have provided their consent. This approach ensures that data collection respects users' preferences while enabling the analysis of traffic segmentation by key metrics like source, medium, and campaign specifics.", "MatomoConfigurationMatomoCustomRequestProcessingTitle": "Custom Request Processing", "MatomoConfigurationMatomoCustomRequestProcessingDescription": "Can be set to a variable of type \"%s\" to augment or override default request sending behaviour.", "MatomoTagDescription": "Matomo is the leading open source analytics platform.", diff --git a/tests/System/expected/test___TagManager.exportContainerVersion_site_default_container.xml b/tests/System/expected/test___TagManager.exportContainerVersion_site_default_container.xml index 944a8576..2defb69f 100644 --- a/tests/System/expected/test___TagManager.exportContainerVersion_site_default_container.xml +++ b/tests/System/expected/test___TagManager.exportContainerVersion_site_default_container.xml @@ -108,6 +108,7 @@ Lax 0 + 0 0 diff --git a/tests/System/expected/test_webContext__TagManager.getAvailableVariableTypesInContext.xml b/tests/System/expected/test_webContext__TagManager.getAvailableVariableTypesInContext.xml index d8f975bc..f5d619d5 100644 --- a/tests/System/expected/test_webContext__TagManager.getAvailableVariableTypesInContext.xml +++ b/tests/System/expected/test_webContext__TagManager.getAvailableVariableTypesInContext.xml @@ -1228,6 +1228,22 @@ 0 + + requireConsentForCampaignTracking + Require consent to track campaign parameters + 0 + 0 + boolean + checkbox + + + + By enabling the consent requirement, Matomo will track campaign parameters only for users who have provided their consent. This approach ensures that data collection respects users' preferences while enabling the analysis of traffic segmentation by key metrics like source, medium, and campaign specifics. + + + + 0 + domains Domains