How to set up dev/staging/prod environments

Hello everyone,

how would I go about setting up different environments for the same site?

Right now, I develop my site locally, then deploy it to a staging environment and when everything is fine, move it forward to the actual production environment.

So I have three different sites that I want to track separately, as only the information from the production environment is relevant for statistics but the others are needed to test if tracking works as expected.

Right now, I do this with three different websites in Matomo. The problem with this is that it’s really hard to set up goals because I have to make sure that they all get the same id’s across all three sites.

It would be easier if I could set up one site but filter the data by domain.

Is this possible? If so, how?

How would you set up different environments.

1 Like

I would not want any non-production information on my production systems. You really want to avoid cross-contaminating data, creating system instability issues, security issues, etc…

The best way to do it is to copy from prod to staging your web and analytics, then copy staging down from there. Beyond staging, none of your data should be real anymore, so anonymize your data in local, dev, test, etc… Fake/dummy data is okay to test with in these environments.

Whatever changes you make to Matomo, just copy them upwards, one environmental level at a time.

2 Likes

I’m talking about dev/staging/prod versions of my website. I use Matomo for analytics on this website.

Yes, I want to keep data from my dev/staging/prod websites apart.

No, I certainly don’t want to maintain multiple Matomo instances.

If Matomo would support proper IaC, I would be happy to maintain separate instances. But everything in Matomo needs to be done via this despicable graphical interface. I hate maintaining one instance, I will certainly not maintain 3 of them.

You mentioned “just copy them upwards”. How would I do that?

Hi @fredfred
You can script a switch depending on the site URL. If URL is the one of dev, then use Matomo dev tracking params (change Matomo URL and / or site ID), if URL is staging one, use Matomo staging tracking params, etc. Very easy to implement…

1 Like

This is exactly the solution I have set up right now. But this means that I need to have a switch that knows about the URL where the site is deployed (especially annoying when your local environment changes ports) and I also have to set up different projects in Matomo (which is annoying because Matomo is not user friendly and does not allow to copy configuration from one project to another which - as per my first post - makes it borderline impossible to set up the goals with the same id’s in all projects).

I’m rather looking for a solution that let’s me throw all data into the same Matomo site but then filter by URL.

Hi @fredfred
How do you track? Could you share your tracking code, with obfuscated sensitive parameters (eg. fake site URL, fake Matomo URL, etc.).
If you don’t separate data from tracking (with switch), you can track in the same instance and separate traffic thanks to segments in Matomo. But I think tracking on different instance (different Matomo servers or simplier just different site ID) would give better results…