I have successfully implemented Piwik website tracking using the GTM method (i.e. we have a Google container on the site, and we’ve added the Piwik’s ‘Custom HTML’ as a tag in GTM).
Piwik allows to track downloads of plenty of file formats. Unfortunately, the .xz format isn’t among them and we need to add it to the list of tracked format.
Looking into the documentation , I found this guide. It says:
You can customize list of file extensions you want to track as downloads. You can add new extensions, to an existing list with addDownloadExtensions:
// add other image formats
_paq.push(["addDownloadExtensions", "svg|xcf"]);
I’m not very proficient with JavaScript. Exactly where I should add this code (I believe the second parameter should be “xz”) given our GTM setup?
your custom code in GTM should contain a line like this
_paq.push(["enableLinkTracking"]);
or at least one with a “trackPageView” command.
Add the line you found above that (even below should not make a difference in that case AFAIK). And you are right: just replace the list in the second parameter with your desired file extension. If you want to add more than one extension, separate them with a |.
Okay, that’s the full Piwik PRO tag manager code. Do you plan to implement tracking in both GTM and another tag manager? If so, you could keep it like it is and add another custom HTML as a clean-up tag (tag sequencing in GTM) for your existing tag that basically only contains the code line you found. That should work as well I guess.
Worked like charm I added this code as another custom tag and enabled sequencing so that this tag would fire before the main Piwik tag. It now successfully registers downloads of files with the xz extension, and all other downloads/goals are being registered well.