Matomo.js is auto-updating: cannot write modification into it

matomo is blocked by easylist: the name matomo.js/.php, AND the GET variable ?action_name=

note that if the action_name= variable is not the first one getting called, it is not blocked.
The solution is to create symbolic links of matomo.(php|js) files and to put another variable before the “action_name” in the URL:

sed -i -e ‘s/action_name=/a=b&action_name=/g’ matomo.js

this will call matomo with:

?a=b&action_name= …

this pass easylist filters.

however the matomo.js seems to be auto-updated very frequently and is overwriting the modification. Anyone has a solution to stop the file from being overwritten ? I’ve though about changing file’s permissions but I’d prefer a more indirect way.

Write a Plugin, this way your code will always be included in the JS.

1 Like

To extend on @fdellwing’s tip:

You need to add a tracker.js file to the plugin and Matomo will automatically add it to the main matomo.js

Hello junkkk,

– I wanted to reach the same goal (bypass ads blockers) and you can do this by using setCustomRequestProcessing in the JS tracker code present in your pages :

var _paq = window._paq = window._paq || [];
_paq.push(['setCustomRequestProcessing', function(request) {
	/* modify request content to your needs */
	request = "a=b&"+request;
	return request;
}]);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);

/* other lines to load the Matomo code */

– To bypass ads blockers, I use https://github.com/matomo-org/tracker-proxy
Following instructions, you get matomo.php, piwik.php, proxy.php and matomo-proxy.php and place them in your root directory.

I renamed matomo.php to m.php otherwise the name matomo is blocked by Ublock origin.
I added to m.php this code to accept alternative GET params name (action_name and idsite are blocked by ads blockers) :

if(isset($_GET['a_name'])) { $_GET['action_name'] = $_GET['a_name']; }
if(isset($_GET['siteid'])) { $_GET['idsite'] = $_GET['siteid']; }

And the JS code present in each page to track users is :

  var _paq = window._paq = window._paq || [];
  
_paq.push(['setCustomRequestProcessing', function(request) {
		request = request.replace('action_name', 'a_name').replace('idsite', 'siteid').replace('idSite', 'siteid');
		return request;
	}]);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);

  (function() {
    var u="//yourdomain.com/";
    _paq.push(['setTrackerUrl', u+'m.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.src=u+'m.php'; s.parentNode.insertBefore(g,s);
  })();

This way my website loads m.php to get Matomo JS code and then Matomo JS code calls “yourdomain.com/m.php?a_name=test&siteid=1” to track users.