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 /core/Tracker | |
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 'core/Tracker')
-rw-r--r-- | core/Tracker/TrackerCodeGenerator.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/Tracker/TrackerCodeGenerator.php b/core/Tracker/TrackerCodeGenerator.php index f736ceb972..6bfba7894d 100644 --- a/core/Tracker/TrackerCodeGenerator.php +++ b/core/Tracker/TrackerCodeGenerator.php @@ -46,6 +46,8 @@ class TrackerCodeGenerator * @param bool $doNotTrack * @param bool $disableCookies * @param bool $trackNoScript + * @param bool $crossDomain + * @param bool $excludedQueryParams * @return string Javascript code. */ public function generate( @@ -61,7 +63,8 @@ class TrackerCodeGenerator $doNotTrack = false, $disableCookies = false, $trackNoScript = false, - $crossDomain = false + $crossDomain = false, + $excludedQueryParams = false ) { // changes made to this code should be mirrored in plugins/CoreAdminHome/javascripts/jsTrackingGenerator.js var generateJsCode @@ -138,6 +141,16 @@ class TrackerCodeGenerator if ($doNotTrack) { $options .= ' _paq.push(["setDoNotTrack", true]);' . "\n"; } + + // Add any excluded query parameters to the tracker options + if ($excludedQueryParams) { + + if (!is_array($excludedQueryParams)) { + $excludedQueryParams = explode(',',$excludedQueryParams); + } + $options .= ' _paq.push(["setExcludedQueryParams", '.json_encode($excludedQueryParams).']);'."\n"; + } + if ($disableCookies) { $options .= ' _paq.push(["disableCookies"]);' . "\n"; } |