diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2021-10-04 07:01:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 07:01:04 +0300 |
commit | 2404b24c3a52f04475b63f300269a129399882ec (patch) | |
tree | 421e1a81c7f554561bec2cf8385d44ad478ed97f /plugins/SitesManager | |
parent | deff627a8e9a4c476ba59cfe57c3797f65679c4f (diff) |
JavaScript tracker exclude query parameters (#18031)
Adds a new option to the JavaScript tracker to exclude query parameters from the tracked URL.
Co-authored-by: bx80 <bx80@users.noreply.github.com>
Co-authored-by: sgiehl <stefan@matomo.org>
Diffstat (limited to 'plugins/SitesManager')
-rw-r--r-- | plugins/SitesManager/API.php | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index d52003a71f..ba3a3c7362 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -90,26 +90,30 @@ class API extends \Piwik\Plugin\API * Returns the javascript tag for the given idSite. * This tag must be included on every page to be tracked by Matomo * - * @param int $idSite + * @param int $idSite * @param string $piwikUrl - * @param bool $mergeSubdomains - * @param bool $groupPageTitlesByDomain - * @param bool $mergeAliasUrls - * @param bool $visitorCustomVariables - * @param bool $pageCustomVariables - * @param bool $customCampaignNameQueryParam - * @param bool $customCampaignKeywordParam - * @param bool $doNotTrack - * @param bool $disableCookies - * @param bool $trackNoScript - * @param bool $forceMatomoEndpoint Whether the Matomo endpoint should be forced if Matomo was installed prior 3.7.0. + * @param bool $mergeSubdomains + * @param bool $groupPageTitlesByDomain + * @param bool $mergeAliasUrls + * @param bool $visitorCustomVariables + * @param bool $pageCustomVariables + * @param bool $customCampaignNameQueryParam + * @param bool $customCampaignKeywordParam + * @param bool $doNotTrack + * @param bool $disableCookies + * @param bool $trackNoScript + * @param bool $crossDomain + * @param bool $forceMatomoEndpoint Whether the Matomo endpoint should be forced if Matomo was installed prior 3.7.0. + * @param bool $excludedQueryParams + * * @return string The Javascript tag ready to be included on the HTML pages + * @throws Exception */ public function getJavascriptTag($idSite, $piwikUrl = '', $mergeSubdomains = false, $groupPageTitlesByDomain = false, $mergeAliasUrls = false, $visitorCustomVariables = false, $pageCustomVariables = false, $customCampaignNameQueryParam = false, $customCampaignKeywordParam = false, $doNotTrack = false, $disableCookies = false, $trackNoScript = false, - $crossDomain = false, $forceMatomoEndpoint = false) + $crossDomain = false, $forceMatomoEndpoint = false, $excludedQueryParams = false) { Piwik::checkUserHasViewAccess($idSite); @@ -125,6 +129,11 @@ class API extends \Piwik\Plugin\API $customCampaignNameQueryParam = Common::unsanitizeInputValue($customCampaignNameQueryParam); $customCampaignKeywordParam = Common::unsanitizeInputValue($customCampaignKeywordParam); + if (is_array($excludedQueryParams)) { + $excludedQueryParams = implode(',', $excludedQueryParams); + } + $excludedQueryParams = Common::unsanitizeInputValue($excludedQueryParams); + $generator = new TrackerCodeGenerator(); if ($forceMatomoEndpoint) { $generator->forceMatomoEndpoint(); @@ -133,7 +142,8 @@ class API extends \Piwik\Plugin\API $code = $generator->generate($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain, $mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables, $customCampaignNameQueryParam, $customCampaignKeywordParam, - $doNotTrack, $disableCookies, $trackNoScript, $crossDomain); + $doNotTrack, $disableCookies, $trackNoScript, $crossDomain, + $excludedQueryParams); $code = str_replace(array('<br>', '<br />', '<br/>'), '', $code); return $code; } |