Track directly downloaded files

Hi,

it is possible to track directly downloaded files (xy.com/file.pdf) with piwik?

If yes, then how? (:P)

No. You could instead set up a proxy to serve those files and use server side tracking.

Hi!

I’ve postet that already in the german section.

There are already some threads but I found no best practice example.

Problem: Piwik does not track direct downloads, since no javascript is executed and the download is sent to the browser direct by the webserver.

Example: http://www.domain.tld/tollesPdf.pdf <-- Download doesn’t get tracked by Piwik

Solution: redirect extensions you like to track to a doorway/proxy site using .htaccess. There you read the file, track it via piwik api and then send the file to the browser.

The problem with that solution would be, that internal Downloads get counted twice.
example. a download link to a pdf on my website --> 1. hit tracked by the Piwik javascript code (click is registered) and the second hit would be, that the webserver recognizes the pdf and redirects to the dooway page and the file is counted a second time.

By theory you can check the referrer on the download page but now it’s getting complicated.

Has anyone a better Solution?
What do you say to the problem that external direct downloads don’t get tracked?

Has anyone a better Solution?

Yes, you could redirect all .pdf .jpg etc. through a proxy track-piwik.php that would

  1. track the request in piwik using the tracking api: http://piwik.org/docs/tracking-api/
  2. forward to / or return the original requested file

If you end up writing such a script, please post a new forum topic it would be great and others will use it for sure!

Hi Matt!

Yes, you could redirect all .pdf .jpg etc. through a proxy track-piwik.php that would

But here we have the problem that it will get counted twice (because still if you use a proxy site it will get tracked by piwik first - see my posting above).

So I see only two solutions if you track all files with a proxy script:
a) deactivate the tracking in Piwik for these exetensions
b) or check in the proxy script if the referrer is from the same domain as the script is running.

I’ll do some test’s - but for that I have to set up a clean/empty piwik.

It will be tracked twice if the “proxy” you are talking about is a “real” (aka “dummy”) proxy that would simply forward the download request or, as you put it yourself, “redirect to a doorway page”. If the proxy actually does the work of serving the file as if it (the proxy) were a full-fledged webserver, the file would be tracked only once, that is when the proxy does the first step in Matt’s reply.

Hi. I have the same requirement with a wordpress site. Did you solve the problem? Regards, Vanessa

In case you are talking about tracking direct downloads, I have written years ago such a small script for Piwik. As far as I know, it is still compatible with the most recent release. It’s called DDT and you can find it either through my old forum posts or on my website https://www.khalemy.com/software/ddt-for-piwik/

Hi @Amenel, I’ve found you DDT, but don’t understand the installation because I’m not very firm with these things. I am a user, not a code generator. I managed to install contao and yesterday I installed PIWIK the first time at all.

I’m sending out PDF files that include links to ZIP files within my contao and I’d like to know if anyone downloads the ZIP file.

After reading very much about this problem I found the DDT and I think that is what I need for tracking these clicks. But I don’t understand, what exactely I have to configure in the files of the extension. I’ll try it this evening (german evening). Could you please help me, if I really do not know what to do? May I ask here or somewhere else? Perhaps via your contact form on your website? Here it would perhaps help more beginners, via your form we won’t disturb users that aren’t as inexperienced as I am. There are advantages and disadvantages.

I recommend you find someone technical around you who is a capable webmaster or system administrator. Beginners who don’t know where to start will need too much teaching and guiding; this is something that I can’t do because the sheer number of possible software combinations between the server, the PHP version, the PHP installation mode and many other factors make it impossible.