Piwik.js is being refreshed to its original state

I have added some extra code in piwik.js.
Its working and giving me results at the same time PIWIK is working fine.
But the problem is: after certain amount of time that code just gets vanished and original piwik.js reappears.
Help is much appreciated.
Thanks

Hi,

This is intentional as Matomo plugins need to add code to the piwik.js to track additional things and this replaces the piwik.js.

But you can use the same technique:

When you create a plugin and add a tracker.js and tracker.min.js to it’s root directory, it’s content will be copied into the piwik.js.

More Information:

You can check how this plugin does it: