Excluding parts of a URL from being tracked by Matomo

Given a URL such as:

www.mywebsite.com/part/12345/view

Is it possible to exclude the 12345 from being tracked by Matomo?

If so, would it be excluded from the transmission to the Matomo server?

Appreciate your help. Thanks!!

Hi,

So you don’t want a website to be tracked if it contains 12345 in the URL.

The easiest way would be to simply change your tracking code so that the trackPageView is only called if this does not match. So a simple if in Javascript should solve the issue.

Thanks for the reply Lukas!

I may have rushed writing out my question.

The 12345 would be considered sensitive data, so we don’t want it tracked. We still want to know about the rest of the URL. The 12345 is a variable so will change, but the value would always be in the same place in the URL.

What are our options?

Does Matomo have the ability to obfuscate the 12345?

Hi,

Ah, in that case you could use a similar solution:

You can use some javascript (probably in combination with a matching regex) to replace that part of the URL with a placeholder and then call _paq.push(['setCustomUrl', obfuscated_url]); with the fixed URL before calling trackPageview