I’ve noticed a number of visits being recorded for one of my sites with http and no www. Thing is the htaccess redirects all traffic to www, and both htaccess and the CMS force https. When I test this, I’m always redirected to the https, www, and the browser language index page (two language site). And Matomo records that, not the http attempt.
I’m thinking these visits are likely bots somehow getting recorded this way. Is there some way I can force these to the correct URL?
I’m interested in the opposite problem - I have a site whose standard URL does not contain “www.” and all hits are appearing in the Matomo statistics as coming from “www.(name of site).com.” There is a redirect so that visitors who enter “www.(name of site).com” will be redirected to the correct URL of “(name of site).com”, but this problem applies even to those who enter the URL without www. in the first place. I can’t find anywhere accessible to Matomo that the site’s name is described with “www.”; it appears Matomo is adding that string to the URL all by itself. But on another site with what appears to be the same configuration, tracked by the same Matomo instance, it does not add “www.”. I wish I could find a way to turn off whatever Matomo is doing here, and have it just record the same URL that the browser is using.
Looks like both problems are the consequence of this one:
Apparently, Matomo somehow “remembers” which of (whatever).com and www.(whatever).com it sees first for each site, and after that it translates both of those to the first one it saw, forever. If you track www.(whatever).com first, then (whatever).com will always be translated to www.(whatever).com. On the other hand if you track (whatever).com first, then www.(whatever).com will always be translated to (whatever).com. There does not appear to be a workaround, like a way to get Matomo to forget this decision once it has been made, short of deleting and re-creating the site. If your site has changed with respect to whether it uses www., in either direction, that’s just too bad.
The problem is labelled a bug on Github and there’s a comment on there saying it has been prioritized, but there have been six releases since then and no fix or progress update so far.
I have now added the http->https redirect via VirtualHost in Apache. Let’s see if that fixes my issue, as the redirect will now happen before any site files are accessed, including the Matomo script.
I think that will only help on a site that is newly added to Matomo. If you have ever tracked a visit with the undesired URL, then it appears you’re stuck with it unless you remove and recreate the site, or they fix the bug. But if you do find a workaround, please let me know, because I’m facing the same issue from the opposite side.