Exclude all url query parameters except some specific ones

I am trying to exclude all url query parameters except 2 ( assistant and returnUrl).
I am using a negative lookahead expression /^(?!assistant|returnUrl).*$/
in measurable --> manage --> Excluded parameters. but I am getting all the URL query parameters. Are there any other ways to achieve this?

Hi,

If the core Matomo features can’t do this, there are two alternatives to do this yourself:

  • While tracking write JS that rewrites the URL to remove those URL parameters and then call _paq.push(['setCustomUrl', yoururl]); with the fixed URL
  • Write a custom tracking plugin for Matomo that rewrites the URL server-side

OK Thanks! So just to confirm, the core Matomo features only allow to exclude parameters. I didn’t know if matomo’s backend engine for regex accepted lookahead expressions. And if a negative lookahead in the case of excluded parameters will have its opposite usual behavior as it is set in the excluded query parameters. I wanted to say exclude all url query parameters except these two.