To measure your websites with Matomo (Piwik) you are likely to use the Matomo JavaScript Tracking code, a small snippet of code that should be added in your websites pages. When visitors view your website, the Matomo tracking code gets executed by the browser and your visitor’s browsers load the piwik.js file from your Matomo server, for example:

In some cases it may be useful to customise the piwik.js tracking code. This FAQ explains the best practise method to let you safely edit the piwik.js file. Note that this is an advanced feature and should be used with great care. First you will need to install and activate the plugin CustomTrackerJs. Login as a Super User in Matomo then go to Administration, click on Marketplace and install the plugin CustomTrackerJs. After activating this plugin, Super User can click on the Admin menu ‘Plugin Settings’ link. Any text entered in the field ‘Javascript code’ will be appended to the content of piwik.js.

For example, if you wanted to enable Content Tracking on all your websites at once, enter the following:

if ('undefined' !== typeof _paq) {

Note: changing piwik.js will affect all your websites at once (all websites load the same piwik.js file). Use this feature with care: if you input invalid JavaScript code then it may create JavaScript errors on your websites.