Plugin documentation

TrackingRouter

Keep every website in its own profile and add a shared profile with continuous sessions: one tracking request, copied on the server to the sites you allow.

Plugin page · from €29/month Try the live demo ↗

Overview

TrackingRouter records one tracking hit in several websites of your Matomo, on the server side.

Own profiles and one continuous session

Keep every website, brand or section in its own Matomo profile, and add a shared profile that sees everything. A visitor who reads your blog, then buys in your shop, appears in the blog profile, in the shop profile, and in the shared profile as one continuous visit: the whole path, the real entry page and referrer, and the order belong together.

Roll-up reports cannot do this: they add up the visits of separate sites, so the same visitor counts twice and the path between the sites is lost.

Prerequisite: in the shared profile, the visitor has to be recognized as the same person on every domain, for example

  • by the same fingerprint (cookieless tracking, nothing to configure),
  • by cross-domain linking for different domain names (enableCrossDomainLinking and setDomains; in Tag Manager "Enable Cross Domain Linking" and "Domains"),
  • by a wildcard cookie domain for a domain and its subdomains (setCookieDomain('*.example.com'); in Tag Manager "Cookie Domain"),
  • or by a User ID for logged-in users.

How it works

The page sends one tracking request with the additional parameter idsites:

matomo.php?idsite=1&idsites=3,4&url=…

Matomo records it as usual for site 1 (the primary site) and, on the server, copies it to each requested site that the primary site allows. Requests without idsites are processed exactly as before.

  • Copies carry the visitor ID of the original request if it has one (cookie, User ID). With cookieless tracking, Matomo identifies the visitor in each site on its own, as it always does.
  • Goal conversions, ecommerce orders, heartbeat pings and custom dimensions are only copied where you enable them.
  • A copy that cannot be recorded is skipped; the original request and the other copies are recorded anyway.

Setup

  1. Primary site: under Administration → Websites → Manage, edit the website, section Tracking Router: turn on Enable fan-out (consent covers the extra sites) and select the allowed extra sites.
  2. Extra sites: goals and custom dimensions are numbered per site. If you copy them, create them on every extra site with the same IDs and meaning.
  3. Website: send idsites with the tracking requests:
    • Tag Manager: in the Matomo Configuration variable, field Append To Tracking Url: idsites=3,4. This is the simplest way for fixed extra sites. For extra sites that change per page (e.g. per section), use a Custom Request Processing function instead. Custom Data with the name idsites works too, as the first custom data entry.
    • matomo.js: _paq.push(['appendToTrackingUrl', 'idsites=3,4']); before trackPageView.

Settings

Setting Default Purpose
Enable fan-out (consent covers the extra sites) off Turns routing on for the primary site and confirms that your visitors' consent also covers the extra sites. The other settings appear once it is on.
Allowed extra sites empty Up to ten sites, listed by name. Requested sites missing here are ignored.
Copy ecommerce orders and cart updates off Otherwise orders are only recorded on the primary site.
Copy manual goal conversions off Requires the same goals with the same IDs on the extra sites.
Copy heartbeat pings off Turn on together with heartbeat tracking for correct visit durations.
Copy custom dimensions off Requires the same dimensions with the same IDs on the extra sites.
Force the visitor ID on the copies off Advanced; only for setups where every request carries a stable visitor ID.

For the whole installation under Administration → System → General settings → Tracking Router: Require Admin access to every extra site. Turn it on as soon as different people or customers manage different websites.

Operation

  • Server load: every extra site means one more tracking request to process. Requests without idsites are not touched.
  • Privacy: every extra site stores its own raw data of the visit. The websites should share the same data controller and consent, which is what the fan-out switch confirms.
  • Multiple servers: changed settings take effect once the tracker cache expires (300 seconds by default), immediately with ./console core:clear-caches.
  • CDN: matomo.php must not be cached by a CDN, because the copying happens on the server.

Working with other plugins

  • BulkTracking: each hit of a bulk request is copied according to its own idsites; BulkTracking's handling of invalid hits is unchanged.
  • QueuedTracking: not tested together with this plugin yet.

Limits

  • At most ten extra sites per request and per primary site.
  • Copies are not forwarded again.

Use cases

  • Own profiles plus a shared one: Every website or section keeps its own Matomo profile and reports. A shared profile additionally sees everything, for example all brands or all regions.
  • Continuous sessions, unlike roll-ups: Roll-up reports only add up separate visits: a visitor moving from blog to shop counts twice and the path breaks. In the shared profile it stays one visit, with the real entry page, referrer and order.
  • One request, one tracker: No second tracker in the browser: the server copies the hit, only to the sites you allow. A failing copy never affects the original, and requests without idsites stay unchanged.

Step-by-step setup

Installation is covered in Installing plugins. Routing is then set up per website. You need admin access to the websites involved in Matomo and access to the tracking code of your pages.

Two terms first: the primary site is the website whose ID is in the tracking code as usual. Extra sites are the websites that should receive the same hit as well.

  1. Secure multi-tenant installs. If different people or clients manage different websites in your Matomo, first open Administration → System → General settings → FeinwerkTrackingRouter and turn on Strict mode: require Admin access on each extra site. Without it, admin access on the primary site is enough to add any other website of the install as an extra site.

  2. Allow extra sites. Open Administration → Websites → Manage, edit the primary site and, in the FeinwerkTrackingRouter section, select up to ten websites under Allowed extra sites. A hit from this primary site can only reach these websites.

  3. Confirm consent. On the same primary site, turn on Extras share consent domain. This declares that your visitors' consent also covers all allowed extra sites, for example because all websites have the same data controller. As long as it is off (the default), the plugin forwards nothing. Extra sites need no setting of their own.

  4. Choose what is forwarded. Pageviews, events, content tracking and other hits go to the extra sites. Four kinds of data stay in the primary site by default and can be enabled one by one:

    • Forward Ecommerce params: revenue may then be counted in several websites.
    • Forward manual Goal conversions: goal IDs are per website, goal 1 may mean something else elsewhere.
    • Forward ping (heartbeat) hits: pings without a prior pageview create orphan visits.
    • Forward Custom Dimensions: slot 1 may mean something different in each website.

    Leave Force visitor id across fan-out (advanced) off. The primary site's visitor ID is copied to every clone anyway. Only enable it if every hit carries a stable ID, such as a User ID.

  5. Extend your tracking code. On pages whose hits should also go to other websites, add the idsites parameter with the IDs of the extra sites. With the JavaScript tracker, do this before trackPageView:

    _paq.push(['appendToTrackingUrl', 'idsites=3,5']);
    

    For direct Tracking API calls, append &idsites=3,5. Matomo processes hits without idsites exactly as before.

First test: open a page with the extended tracking code, then open Visitors → Visits Log for one of the extra sites. The pageview should appear there as in the primary site. If it is missing, check: is the ID listed under Allowed extra sites? Is Extras share consent domain on? Does the tracking request really contain idsites (browser developer tools, network tab)?

Practical examples

Brand sites plus a group roll-up. Three brands each have their own website in Matomo (IDs 2, 3 and 4), and the group wants to see all visits in one shared website (ID 1) as well. On each brand site, add ID 1 as an extra site and turn on the consent setting, and each brand's tracking code sends idsites=1. The group site then holds all hits as its own visits and can be analysed like any other website.

One section for its own team. The careers section under /careers of the company website (ID 1) should also land in an HR website (ID 7) that only the HR team can access. Only pages under /careers send idsites=7, all other pages stay unchanged.

Sections into several profiles. A portal (ID 1) also counts section A in site 2, section B in site 3 and section C in both (idsites=2,3). A single tracker on the page is all it takes.

Shop with separate revenue. The shop (ID 5) also forwards to the group site, but revenue should only count in the shop. Leave Forward Ecommerce params off, and orders and revenue stay in the shop website.

Good to know

  • Limits: at most ten extra sites per primary site and per hit. Forwarding is single-hop, so clones are not forwarded again. IDs in idsites that are not allowed are ignored.
  • Permissions: admin access on the primary site is enough to maintain its extra sites. In strict mode, admin access on each extra site is required too.
  • Privacy: every extra site stores its own raw data of the visit. Only turn on the consent setting if the websites share the same data controller and the same consent.
  • Stability: a failure on an extra site does not affect processing for the primary site.
  • Server load: every extra site means one more tracking request on your server. With more than two extra sites on average, use the QueuedTracking plugin, which queues each clone independently.
  • Caching: the matomo.php tracking endpoint must not be cached by a CDN, because the forwarding happens on the server.
  • Multiple servers: changed allowlists take effect on each server once the tracker cache expires (300 seconds by default). Run ./console core:clear-caches on each server for an immediate effect.
  • Bulk tracking: each hit in a bulk request is forwarded according to its own idsites.
  • Upgrading from TrackingRouter: if you use the predecessor TrackingRouter (up to 1.x), install and activate FeinwerkTrackingRouter. It takes over all settings and removes the old plugin, with no change to your tracking code.

Technical reference

PropertyValue
Technical nameFeinwerkTrackingRouter
Current version2.1.1
Matomo≥ 5.0.0, < 6.0.0
PHP≥ 7.4.0
Licensepaid
Database changesnone in the current version

FAQ

How is this different from Roll-Up Reporting?

Roll-Up Reporting adds up the reports of several sites. Each site still has its own visits, so a visitor who moves from one site to another counts as two visits and the path between them is lost. TrackingRouter records the hit in a shared profile as well, where pages of all sites form one continuous visit. Reports per site stay available in their own profiles.

What do I need for continuous sessions across domains?

The visitor has to be recognized as the same person on every domain of the shared profile: without cookies by the same fingerprint, with cookies by cross-domain linking (different domain names) or a wildcard cookie domain such as *.example.com (subdomains), or by a User ID. Otherwise each domain starts a new visit in the shared profile; the profiles of the individual websites are not affected.

Do I need to change my tracking code?

Only where hits should also go to other websites: add idsites, e.g. with appendToTrackingUrl in matomo.js or the "Append To Tracking Url" field in Tag Manager. Everything else keeps working unchanged.

Do goals and custom dimensions carry over?

Only if you enable it per type, and only if the extra sites have the same goals and dimensions under the same IDs, because these IDs are numbered per site. Events, content tracking and site search need no preparation.

Is the visitor ID the same in every site?

If the request carries one (cookie, User ID), the copies keep it. With cookieless tracking, Matomo identifies the visitor in each site separately, as it always does; visits within each site, including the shared profile, are formed as usual.

How is consent handled?

A switch on the primary site declares that its visitors' consent also covers the allowed extra sites. As long as it is off (the default), nothing is copied.

What about performance?

Requests without idsites are not touched. Each extra site means one more tracking request for your server to process. QueuedTracking has not been tested together with this plugin yet.