@marcojarjour opened this Issue on September 5th 2022

Expected Behavior

I would assume that only Downloads with file extensions defined in setDownloadExtensions are tracked.

https://developer.matomo.org/guides/tracking-javascript-guide#tracking-file-downloads

Current Behavior

When a link contains the download attribute, it is always tracked regardless of what is defined in setDownloadExtensions

Possible Solution

I am not sure what others expect, but i would assume it should also respect the extensions list, therefore the following javascript would need adjustment.
https://github.com/matomo-org/matomo/blob/3ce98e84490f22324315a616e6886b63db48d5d0/js/piwik.js#L4202

Steps to Reproduce (for Bugs)

  1. Ensure Download Tracking is enabled
  2. Add the following snippet to a tracked website
  3. The test download is not tracked
  4. The test download - always tracked links is tracked as download.
  5. Verify it via Visitors -> Real-time
<a href="test.does-not-exists">test download</a>
<br>
<a href="test.does-not-exists" download>test download - always tracked</a>

Context

  • I would like to disable all downloads from the JavaScript tracker
  • To setup a downloads tracking via access.log import to also track direct downloads

Your Environment

  • Matomo Version: 4.11.0
  • PHP Version: 8.0.22
  • Server Operating System: Debian Bullseye
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@sgiehl commented on September 5th 2022 Member

Hi @marcojarjour . Thanks for creating this issue.
I guess I would actually disagree here. Setting download extension can be used to have downloads automatically detected.
Setting the attribute, though, is a way to manually enforce a link to be a download.
The could be links like https://example.org/file/download, which actually do not even have a file extension, or something like https://example.org/download.php?fileId=374453, where you can't add the extension as download. For those cases it's needed to have a possibility to force a download tracking even if the extension doesn't match.

Regarding your context:
If you would disable tracking downloads using javascript, but import all downloads using log importing instead, it will most likely happen that the imported downloads will create a lot new visits, as those visits can't be associated with the visits tracked by javascript.

@marcojarjour commented on September 5th 2022

Hi @sgiehl
Thanks for your fast response.

I guess this is another view on this, i though to enforce to be tracked as download the _paq.push(['setDownloadClasses', "download"]); is used, but i am fine with your opinion.

Thanks for the sidenote about my usecase, this means:
Even if i only import access logs, which ends, for example, in *.pdf, this would not only be counted as download but as visit too?

@sgiehl commented on September 5th 2022 Member

Thanks for the sidenote about my usecase, this means:
Even if i only import access logs, which ends, for example, in *.pdf, this would not only be counted as download but as visit too?

Yes. A download is an action. And each action tracked will be associated with a visit. If no visit can be associated automatically using the config id, a new visit will be started for this action.

@marcojarjour commented on September 5th 2022

This was not my intention, but thank you very much for pointing this out.
And about the download tracking, this was not logical for me but your opinion also makes sense and therefore from my side this issue can be closed.

Thanks for your time!

This Issue was closed on September 5th 2022
Powered by GitHub Issue Mirror