Skip to content

WP MultiSite

Thomas Steur edited this page Aug 2, 2021 · 5 revisions

Matomo differentiates between two different multi site modes:

Matomo is network enabled

In this mode, the tracking and access settings are managed in the network admin in one place and apply to all sites. An administrator of a site cannot view or change these settings.

The privacy settings have to be configured per site currently as they are done in the Matomo admin.

Matomo is not network enabled

In this mode, the tracking and access settings are managed by each individual site / blog. They cannot be managed in one central place for all sites. An administrator of a site / blog or any user with the "Matomo super user" role can change Matomo settings per blog.

Behind the scenes

Tracking endpoint

Each WP blog within a multisite installation has their own URL, for example https://example.com/blog1 and https://example.com/blog2. The generated Matomo tracking endpoint uses the blog's URL, for example https://example.com/blog1/wp-content/plugins/matomo/app/matomo.php and because of the blog URL the correct blog is detected.

JS tracker

In WordPress each blog has their own upload path. For example wp-content/uploads/sites/1/ and wp-content/uploads/sites/2/. For each blog we generate the JS tracker file individually eg. wp-content/uploads/sites/1/matomo/matomo.js. This is important because different blogs can have different plugins and different configurations.

Data storage

Matomo is installed for each blog individually. It's NOT one Matomo installation where each blog has a different idsite. By having a separate Matomo installation in the background

  • each WP blog can configure Matomo differently which would otherwise not be possible.
  • it makes big Matomo log table schema changes faster because we have many smaller tables instead of one big table.
  • there are many DB tables to migrate when there is a DB update which is a downside.
  • we can currently now show or generate a report across all blogs.

Each blog has a different DB prefix in WordPress. For example blog 1 might have a prefix wp_1 and blog 2 might have a prefix wp_2 meaning there is eg a wp_1_matomo_log_visit table and a wp_2_matomo_log_visit table. Depending on the blog URL WordPress will set the correct DB prefix automatically.

Managing many sites

If someone is managing quite a few sites or has quite a bit of traffic then we recommend installing Matomo On-Premise separately outside WordPress (it's free as well) and use it in combination with the WP-Matomo WordPress plugin. Matomo will then run a lot faster, Matomo can be put on a separate server if needed, and it allows making use of additional features such as Roll-Up Reporting.

If someone doesn't want all the hassle of maintaining a Matomo then we recommend signing up for a free Matomo Cloud trial. We can migrate existing data onto Cloud for free.