Tracking code evolutions

Hi,

I’m the developper of the ngx-matomo library that simplifies the integration of Matomo in an Angular app.

I automated the injection of the tracking code into the page, freeing the developper from manually modifying the HTML page.

I started to test my demo app with Matomo SaaS and found a few modification in the tracking code:

  • piwik.php is now becoming matomo.php. Is piwik.php going to be maintained for some time or shall I start I provide a way for using one or the other depending on which version of Matomo is used?
  • Same question for piwik.js / matomo.js
  • Lastly, for the matomo.js script for Matomo SaaS, the URL is quite different from the one we have by default when installing the Matomo from scratch. Is it a common use case to have this URL being modified or is it specific to Matomo SaaS?

Hi,

piwik.js and piwik.php will likely be removed with Matomo 4, coming some time in the future. New and updated applications should use matomo.js and matomo.php as these are the new default endpoints.

Your last question I’m unable to answer.

Hi,

I’m pretty sure piwik.js and piwik.php will continue to work for longer than just Matomo 4 as changing it would break a lot of things.
With Matomo 4 it will just be the default everywhere and everyone should be using it.

I’m not entirely sure what you mean? Are you referring to the CDN?

On Cloud here is the possibiliy to load the matomo.js from CDN which means there is a different URL in g.src.
I guess the best way is to optionally provide a parameter so people can override the default matomo.js URL.

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://example-lukas.innocraft.cloud/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src='//cdn.innocraft.cloud/example-lukas.innocraft.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Thanks a lot for your answers!

I’ll stick to piwik.php and piwik.js for the time being. I’ll change it if you introduce a breaking change later on in Matomo.

For the second question, it was related to the CDN, so I stick to your advice and provide an additional optional parameter for it.