mikkonen.com

Fixing Matomo tracking for modern web

Matomo tracking seems pretty much unusable with the default setup it is providing. This is a short checklist on fixing it to see a more realistic view on website's visitors (at the same time, I'm using this post to test publishing something with Pelican).

  1. Check that default piwik.php and piwik.js filenames are not being used. With piwik.php, symlinking it to something like p.php is useful.
  2. In case of the piwik.js, more advanced approach is required, action_name and references to piwik.php should be changed (e.g. to p.php if you used that), action_namecan be like kissmygdpr.
  3. Files piwik.php and piwik.js should not be edited, do a symlink e.g. in case of piwik.php, and in the case of piwik.js, create a PHP file that opens the piwik.js file, and generates something like whatsthis.data using strtr function to replace the things that hit adblockers. Using an extension like .data ensures that pattern matching to .jsextensions is not picking the file.
  4. Configure your webserver to serve the .data file as JS mimetype.
  5. Edit your tracking script to point to the generated and files produced by symlinking.
  6. Use the setting _paq.push(["disableAlwaysUseSendBeacon"]); in the tracking script, beacons are likely to get blocked by anti-tracker settings.
  7. To pass Matomo file integrity checks, use the fileintegrity.ignore in config.inifile with the files you want to ignore.

By using these steps, Matomo tracking should finally be usable once again in the world of modern web.