Skip to content

Commit

Permalink
Merge pull request #766 from matomo-org/dev-17829-feature-consent-tra…
Browse files Browse the repository at this point in the history
…cker-code-generator

Add 'require consent for campaigns tracking' setting
  • Loading branch information
AltamashShaikh authored Mar 18, 2024
2 parents 07d8475 + 2fdb171 commit 590f568
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Template/Tag/MatomoTag.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
tracker.disableBrowserFeatureDetection();
}

if (matomoConfig.requireConsentForCampaignTracking) {
tracker.disableCampaignParameters();
}

if (matomoConfig.disableCookies) {
tracker.disableCookies();
}
Expand Down
4 changes: 4 additions & 0 deletions Template/Variable/MatomoConfigurationVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ public function getParameters()
$field->inlineHelp = Piwik::translate('TagManager_MatomoConfigurationMatomoDisableBrowserFeatureDetectionInLineHelp',
['<br><strong>', '<a href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/how-to/how-do-i-disable-browser-feature-detection-completely/', null, null, 'App.TagManager.getParameters') . '" target="_blank" rel="noreferrer noopener">', '</a>', '</strong>']);
}),
$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');
Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<cookiePath />
<cookieSameSite>Lax</cookieSameSite>
<disableBrowserFeatureDetection>0</disableBrowserFeatureDetection>
<requireConsentForCampaignTracking>0</requireConsentForCampaignTracking>
<domains>
</domains>
<alwaysUseSendBeacon>0</alwaysUseSendBeacon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,22 @@
<condition />
<fullWidth>0</fullWidth>
</row>
<row>
<name>requireConsentForCampaignTracking</name>
<title>Require consent to track campaign parameters</title>
<value>0</value>
<defaultValue>0</defaultValue>
<type>boolean</type>
<uiControl>checkbox</uiControl>
<uiControlAttributes>
</uiControlAttributes>
<availableValues />
<description>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.</description>
<inlineHelp />
<introduction />
<condition />
<fullWidth>0</fullWidth>
</row>
<row>
<name>domains</name>
<title>Domains</title>
Expand Down

0 comments on commit 590f568

Please sign in to comment.