Does Matomo Play Nicely With Domain Forwarding To A Subdomain With WordPress Sites?

Hi guys -

I’m wanting to see if anyone’s successfully done something I’m thinking about doing…but first a little background:

I’ve been using Matomo on my business website for several years, which was created with (gulp) Apple’s iWeb '09. It’s currently a very simple site with only a few pages. Piwik has worked okay for the most part, but I’m really needing to update it to WordPress, as I have a much larger and more complex site update in mind, and the WP plugin delivers much more and better info than I get now.

My web hosting plan allows me to create an unlimited number of subdomains and databases, and I’ve successfully created and tested Piwik with several different WordPress installations on their own unique subdomains (i.e. testsite1.mydomain.com, testsite2.mydomain.com, testsite3.mydomain.com, etc), so I’m familiar with how to set all that up.

Now that I’m very close to a final version, I was wondering about something that might make my life easier or harder…how - or if - Matomo might work with domain forwarding to a subdomain (example: pointing www.mydomain.com to testsite3.mydomain.com).

I actually did a brief experiment with this a few months ago, and the results weren’t good.

I created a very basic version of my new WordPress site, and my plan was to temporarily make it public via a domain forwarding redirect pointing to testsite3.mydomain.com. I’d then delete/create a clean database and fresh WordPress install under my primary domain, copy in the assets and settings of testsite3 and add lots more content (lots audio/video files and individual pages) under a different WP theme. Then, several weeks later when I was finished, I’d remove the redirect to point everyone back to the primary, as normal (I also thought forwarding to a subdomain might also be the easiest solution when I wanted to do future temporary versions of my site, such as changing to a one-off seasonal holiday theme).

Unfortunately this didn’t quite work as hoped when I attempted what I thought would be a quick and easy proof of concept test a few months ago. :frowning:

First, Piwik didn’t show anything happening under mydomain.com after I set up the subdomain forwarding from my primary domain. I don’t think I remember seeing anything in testsite3.mydomain.com either, but I’m not 100% sure - the forwarding made some unexpected changes to my PHP settings across my site, and this broke critical parts of the backend for other apps not related to my website or Piwik, so I had to immediately abandon these tests and restore my previous configuration very quickly.

This was a bit of a hassle and very scary, so after fixing everything, I’ve not touched any of the sites since.

I’ve recently rerouted some of the trouble spots I encountered so I hopefully won’t see them again, and I want to try another swing at this…but first, I was wondering if anyone else has successfully managed to get this kind of configuration working, or - assuming it works at all - if it’s too much trouble?

Thanks!

Hi,

So your issue is that no visitior data is appearing anymore once you moved your site to a subdomain?

Have you checked if you added your URL to the website settings or have unticked that box?

Of topic tip:

Are you doing 301 redirects? If yes, you should definitely change that, as they could cause permanent issues.
When you redirect from example.com to test.example.com via 301, it tells visitors to never again check example.com but instead directly visit test.example.com. Even if you remove the redirect, browsers are allowed to cache them permanently.