Matomo Application JS errors

After installation and configuration we experience following situation.

Not sure what’s wrong. Tracking seems to be working fine (except the issue Matomo integration not activated for unautenticated user - Help / Discuss - XWiki Forum which might not be related to following errors).

JS errors

JS console shows four errors

The method setTrackerUrl is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Matomo trackers documentation: https://developer.matomo.org/guides/tracking-javascript-guide#multiple-piwik-trackers

The same for setTrackerUrl, setCookieDomain, setDomains and setSiteId.

Tracking code with HTML-encoded brackets in Admin code preview

After installation and configuration of Matomo Application we do see HTML-encoded brackets in Tracking code snippet in Administration.

but in the generated HTML code of the page the code is inserted properly.

      <script type='application/json' id='attachment-validation-filesize-configuration'>{"maxFileSize":107374182400}</script>

### Matomo script start here
      <script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.test.domain"]);
_paq.push(["setDomains", "*.test.domain"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.domain/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 3]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
### Matomo script end here

      <div role="navigation" class="menu-horizontal-toggle" aria-label="Menu"><div class="navbar-header"><p><button aria-controls="menu-horizontal-Menu-METAIS-Menu-WebHome" aria-expanded="false" class="navbar-toggle collapsed" data-target="#menu-horizontal-Menu-METAIS-Menu-WebHome" data-toggle="collapse" type="button">

The code is correct as proposed in the Matomo Administration.

Just discovered the JS errors are caused by the installation on Main wiki and accessed sub-wiki.

Disabling configuration option “Multiwiki tracking” on both instances cleared the JS errors.

Enabling on either side caused JS errors on the other wiki.