- Issue created by @leipomalla
The script the module is producing to the head of source code is wrong.
I installed Matomo module via composer and added the site ID and a custom script in the UI. However the script that is manifesting on the head is faulty, or at least it's nothing like the one that e.g. WordPress plugin creates.
I put the tracking script to a field 'Code snippet (before)'. The script:
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setExcludedQueryParams", ["fbclid","time"]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//xxx/js/";
_paq.push(['setTrackerUrl', u+'tracker.php']);
_paq.push(['setSiteId', 'xxxx']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'piwik.min.js'; s.parentNode.insertBefore(g,s);
})();
The end result (script in the head):
<script>
var _paq = _paq || [];(function(){var u=(("https:" == document.location.protocol) ? "xxx/" : "xxx/");_paq.push(["setSiteId", "xxxx"]);_paq.push(["setTrackerUrl", u+"matomo.php"]);_paq.push(["setDoNotTrack", 1]);var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setExcludedQueryParams", ["fbclid","time"]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//xxxx/js/";
_paq.push(['setTrackerUrl', u+'tracker.php']);
_paq.push(['setSiteId', 'xxxx']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'piwik.min.js'; s.parentNode.insertBefore(g,s);
})();if (!window.matomo_search_results_active) {_paq.push(["trackPageView"]);}_paq.push(["setIgnoreClasses", ["no-tracking","colorbox"]]);_paq.push(["enableLinkTracking"]);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+"matomo.js";s.parentNode.insertBefore(g,s);})();
</script>
I am also wondering about the required field 'Matomo HTTP URL'. It was impossible to leave that empty so I emptied it in the configs after exporting them. In the live site I tried to edit the custom script a bit but after that I was forced to add an Matomo url, and it's probably wrong one. Instructions are a bit vague imho; should this be an external url to the Matomo account or the site's url and the path to the module?
Active
1.21
Miscellaneous