Downloads, track only one file type - import_logs.py

Hello,

I’m trying to track the number of downloads of pdf files on a website (a Nextcloud instance), based on the Apache logs + the import_logs.py script. When running the import script with the default configuration:

./import_logs.py --url=http://myserver/piwik/ --token-auth=mytoken --idsite=20 --recorders=4 --enable-static /var/log/httpd/oc-access_log

It imports all the data successfully, but when going to the “Behaviour > Downloads” tab it is cluttered with .js, .css, .png etc etc…files and the .pdf files are not really visible.

So the help of import_logs.py tells us to use this:

–download-extensions DOWNLOAD_EXTENSIONS
By default Matomo tracks as Downloads the most popular file extensions. If you set this parameter (format: pdf,doc,…) then files with an extension found in the list will be imported as Downloads, other file extensions downloads will be skipped.

So let’s try the same command as previously, with the addition of the download-extensions flag (on a new empty Site ID)

./import_logs.py --url=http://myserver/piwik/ --token-auth=mytoken --idsite=21 --recorders=4 --enable-static --download-extensions=pdf /var/log/httpd/oc-access_log

…and it produces the same result :frowning: I was expecting only the .pdf files to be displayed in the “Behaviour > Downloads” tab.

Am I missing something?

Welcome to the Matomo forum. You could use Segments to filter PDF files. Something like this:

https://matomo.org/docs/segmentation/#2-segment-configuration

Segments won’t work in such case (segment ≠ filter), because the they are applied on visits. So if during a visit a user access a PDF file, you’ll see all files the user acceded during his visit…

Indeed, I just tested the segment and all files the visitor has seen during the session are displayed.

Sorry, Thank you to make this clear.