How does matomo create the tracking URL? I want to change it

We have a matomo site in our intranet under analytics.intra.<domain>.com
The tracking js etc are publicly available under analytics.<domain>.com.

I want the tracking code to contain the publicly available URL of course. But the code that’s being generated when I add a new site always contains the intra domain, even though the trusted URLs are configured with the pubic URL first - I have not found any other place where the URL is configured.

Please advise, anything helps! Thank you.


So you want to modify how the default tracking code that Matomo generates looks like (of couse you can always modify the tracking code when copying it into the site)

A custom plugin similar to this should work:

Thank you for your quick reply, I highly appreciate it!
I only really want to change one bit of the URL - a dedicated plugin seems a bit overkill? Where does matomo pull the URL it puts in the code from? Because if it’s the current URL, I’d just put the web interface on the public URL and be done with it. I’m not a dev, I’m the infrastructure guy tasked with setting this up.

modifying the tracking code after copying is problematic because users will do it and I don’t trust users with modifying code … you know how it is. They will mess it up and I will be the one to fix it afterwards


The Matomo URL seems to come from here:

which seems to read the DB option piwikUrl.

Modifying that seems not that easy, so I’d recommend you to go the plugin way. It really just needs to be a really trivial plugin with less than 20 lines of code.

1 Like

thanks again, appreciate it.

It is the current URL the Matomo GUI is called from btw. I moved Matomo to the public URL just for shits and giggles and voila - the URL is the the one without intra.

1 Like