Skip to content

Sites analytics

Sites analytics gives each site its own Matomo site ID and URL and its own Google Tag ids, and lets a site switch tracking off. Matomo and Google Tag keep rendering the tracking code; Sites analytics replaces the ids they read with those of the current site. A site that leaves an id empty tracks into the global one, so Hydrion and Torqline can report to Matomo sites of their own while Valtora uses the platform's. Sites analytics adds no consent banner; set one up with a module of its own.

Install

A project of its own, drupal.org/project/sites_analytics:

composer require drupal/sites_analytics
drush en sites_analytics

Requires Sites.

Configure

  1. Install Matomo, Google Tag or both. Without either, the status report warns and a site's Analytics section shows only a hint.
  2. Configure them as the fallback for every site: Matomo at /admin/config/system/matomo, Google Tag at /admin/config/services/google-tag.
  3. With Google Tag, a site's ids replace those of one tag container. When Sites analytics or Google Tag is installed and Google Tag has no container yet, Sites analytics creates one named Sites analytics. If you have a container already, enter its machine name in Google Tag container: as the Preset value on each site type, or in a site's Analytics section.
  4. On each site type, tick Value per site for the ids its sites set; Matomo URL and Google Tag container are always available.
  5. Fill in each site's ids in its Analytics section, in the System group of the site dashboard. It takes Manage site settings on the site; the fields are listed in Site settings.

To track production only, tick Value per environment for Disable tracking on the site type, then tick Disable tracking on this site on the section's Environments tab for each test environment (Environments).

Disable tracking on this site switches Matomo's tracking off and the site's tag container with it. With several Google Tag containers, the next enabled one then tracks in its place.

Settings

The setting plugins it adds, with their keys on Site settings:

Admin pages

Path Title
/admin/sites/{site}/analytics Analytics

Last updated 2026-10-16

Used in