This guide applies to Matomo core developers. If you develop a plugin and want to share it as a contributor please check out the guide for Enriching the Matomo JS Tracker.
It means we need to support older browsers. If you're not sure if a certain method is supported by all the required browsers, then you can use Can I Use website to find out.
Generally we try to keep the JS file smallish for fast performance.
To make changes to the JS tracker, you need to edit the raw/unminfied JS tracker itself which you can find in the js/piwik.js directory. When you create a pull request, you can then minify the JS tracker see below.
See adding tests guide.
The file containing all tests is located in
To execute tests for a specific module use the
module URL parameter, for example
If you are developing multiple tracker plugins and want to only include tests for a specific tracker plugin (like Travis would do) use the URL parameter
plugin as in
Sometimes you may want to test private methods that aren't exposed in the JS tracker API. This can be done by following these steps:
To access private tracker variables that only exist within a tracker instance, you can place extra tracker methods between
/*</DEBUG>*/. Any code between these comments will be removed in the final minified JS tracker version. You can see this done for example here: https://github.com/matomo-org/matomo/blob/4.2.0/js/piwik.js#L4820-L4840
You can then access these methods on a tracker instance as usual. For example
When you create a pull request for a JS tracker change you will notice that a test will fail because the minified version wasn't updated. To generate the minified version for a JS tracker change simply create comment in the PR with the words
If you are reviewing a pull request from a community contributor and you are happy with the change, then follow these steps:
editPR in the top
If you need to debug the tracking code for a plugin that is not behaving correctly on a website you do not control, for example, a client or customer's website, this strategy can help:
Note: depending on the plugin you are testing, you may want or need to adjust what tracker methods are called.
Once you're receiving tracking requests from the website, you may want to modify the tracking code that is used in order to
debug an issue or just get better insight into what's happening. You can do this by modifying the plugin's
(or the core
./console custom-matomo-js:update --ignore-minified
This strategy can help increase the speed of debugging complex issues that you do not know how to reproduce locally