Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No option to create new staging website for use in SiteID variable and matomo tag manager #1246

Open
ozchris opened this issue Jan 17, 2025 · 4 comments

Comments

@ozchris
Copy link

ozchris commented Jan 17, 2025

Trying to follow instructions at https://matomo.org/faq/tag-manager/how-do-i-track-my-staging-dev-production-websites-automatically-using-the-same-tag-manager-container/ to create a separate staging and local website, so that I can use a lookup table to define the SiteID, for use in matomo tag manager.

The instructions at https://matomo.org/faq/how-to/create-and-manage-websites/ suggest a new website can be created via matomo admin under the measurables menu.
However the measurables menu only shows goals and custom variables - there's no websites option.
Is this not available for wordpress matomo?

My hosting allows me to easily create a staging site, but I'd like to avoid logging matomo analytics when on staging - or at least to be able to separate them.

Is this possible, or is there a simple article that explains how to achieve this with the plugin version?

Cheers

@diosmosis
Copy link
Member

Hi @ozchris, that FAQ is for the standalone Matomo product and only applies to self-hosted Matomo or Matomo Cloud.

Can you tell me if the staging site you create uses the same database as your production site? If they do not, then the tracked data should automatically be separate, as it will go to different databases depending on whether you are on staging or production.

@ozchris
Copy link
Author

ozchris commented Jan 19, 2025

Hi @diosmosis

It uses the same database. It uses this approach - https://au.siteground.com/tutorials/staging/create-staging/ - copying the whole database and codebase combined, to a different subdomain eg staging.mysite.com. Then you push back to live with one click.

I had hoped to use matomo tag manager to test the URL and not track (or even better, to track to something identifiably different like a website, so I could test and filter it out later).

I'm used to doing that in google tag manager, setting up variables that test the hostname, and track to different ga accounts using lookup tables.

I'm very new at matomo and haven't personally used their tag manager yet on a live site.

What do most people do, if they're using matomo and push from a staging site to production?

Cheers, Chris

@diosmosis
Copy link
Member

I believe using Matomo Tag Manager in that way would be possible, but I don't think you need to do that work.

If the production database is copied when creating a staging environment, that means that staging does not in fact use the same database, but a copy. Which means the staging environment will automatically track to that database and not the production one.

For a self-hosted Matomo, Matomo Cloud or Google Analytics, this wouldn't work, since the analytics instance is hosted separately from WordPress. You would need to change the tracking code URL through some mechanism (such as detecting the host as you mentioned).

But Matomo for WordPress will simply track to the current host. So, eg, production.mysite.com would track to production.mysite.com/wp-content/plugins/matomo/app/matomo.php and staging.mysite.com would track to staging.mysite.com/wp-content/plugins/matomo/app/matomo.php.

You could test this by creating a staging environment, then viewing a couple pages on your production site, then checking whether those pageviews appear in the Visits Log of your staging environment.

@diosmosis
Copy link
Member

Hi @ozchris, do you still need help with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants