This applies only if you have Matomo for WordPress network enabled in MultiSite and you want to configure the tracking code manually. As the tracking code is saved for the network and will be used across all blogs, you need to use variables in the tracking code which will be replaced with the actual values on demand:

  • {MATOMO_IDSITE} – will be replaced eg with 1
  • {MATOMO_API_ENDPOINT} – will be replaced eg with https://example.com/wp-content/plugins/matomo/app/matomo.php
  • {MATOMO_JS_ENDPOINT} – will be replaced eg with https://example.com/wp-content/uploads/matomo/matomo.js

Here’s an example:

<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setTrackerUrl', {MATOMO_API_ENDPOINT}]);
_paq.push(['setSiteId', '{MATOMO_IDSITE}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; 
g.src={MATOMO_JS_ENDPOINT}; 
s.parentNode.insertBefore(g,s);
</script>
<!-- End Matomo Code -->
Previous FAQ: Does it support WP MultiSite?