May 23, 2017, 9:26pm
I’m using Piwik 3.0.3 and am attempting to modify my tracking code to add download extensions, like such:
I’ve read that I need to use CustomTrackerJs plugin but that doesn’t seem compatible with 3.0.3, or at least there’s no obvious way for me to use it (checked Plugin Settings).
Alternatively, is it safe for me to manually edit my piwik.js file server-side?
If anyone can offer help I would be very grateful.
For reference, this is the set of instructions I’ve attempted to follow:
May 24, 2017, 6:02am
I think you have misunderstood something. You’ll newer need to modify
piwik.js (except when you are a writing a plugin).
This line needs to be added to the tracking code which you have added to your website and should look like this
<!-- Piwik -->
var _paq = _paq || ;
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script');
<!-- End Piwik Code -->
(Ideally before the line
January 22, 2018, 5:36am
I have the same query as above.
I am writing a function in piwik.js and on the click of a button on my website I call that function.
That function is working.
BUT-> The piwik.js removes that function after a certain period (30 minutes approx) automatically.
I too have installed customtrackerjs plugin which is not comaptible.
Help will be much appreciated.
January 22, 2018, 5:48am
In that case check what I have written here:
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:
January 22, 2018, 7:07am
Small note: Keep in mind that the piwik.js is loaded asynchronously, which means it isn’t guaranteed that the function has already been loaded when the user clicks on the button.
When you call
_paq.push([‘addDownloadExtensions’, “pkg|msi|spk|bin”]); from your code it works the same before and after Matomo was initialized.