Quantcast
Channel: Piwik Forums - Support & Bugs
Viewing all articles
Browse latest Browse all 4243

Tracking direct downloads with Piwik (script inside) (no replies)

$
0
0
Hi all,

I'm reposting a previous post I made ten days ago that apparently was lost in the moderation queue.

Preamble
The need for tracking direct downloads has arisen for many of us in these short lives of us as web analytics freaks. The forum has many a thread talking about that need, including this thread: [forum.piwik.org]

This thread purports to satisfy the said need.

What is a direct download?
A direct download is a link to a file that does not appear in a web page as a hyperlink. Put differently, the link below is a direct download IF it appears in an e-mail message (for instance) or if it's entered by a user in their browser's URL field.

http://example.com/downloads/dummy.pdf


It is NOT a direct download if it's part of a normal <a href="some.site.com/link"> construct embedded in a web page.

Down to business
So, tired of not being able to track those downloads, I've decided a few hours earlier today to knock together a working download script that will allow me to track direct downloads. The resulting script is available as an attachment to this post. It's very much an unabashed copy-paste from

http://www.richnetapps.com/php-download-script-with-resume-option/


that has been augmented with:
  • the MIME type for PDFs,
  • Piwik-specific code based on [piwik.org]

Instructions
Just drop the file into a (reachable!) folder on your web space/web server and adapt the variables per the one-line instructions in the file. From then on, all download links you send, share, publish, etc. should look like the one below if you want to be able to track direct downloads:

http://yourOwnSite.com/<your custom path here>/download.php?file=<name of your file or path to it>


Note that <your custom path> will be empty if the "download.php" script is at the root of your server. In that case, you'll need only one forward slash. Example (for my own website):

http://waavSolutions.com/download.php?file=blablabla.pdf


Support
I do not offer support as the initial needs, the purpose, and the instructions are quite straightforward. But if you're really stuck you can still contact me via my website.

Caveats
None that I can think of five minutes after sealing this. All my needs are covered and I haven't noticed any unwanted effects such as counting a visit twice.

Download
Actually, the forum software won't let me attach the script to this post. So here you go (you're gonna have to copy paste, the forum won't turn this into a URL):

http://waavsolutions.com/download.php?file=download.php

How do we thank you?
As some here may know, I'm not just a software engineer; I'm also a (better than good but don't take my word for it!) English to French translator. To thank me, just send work my way when you need an excellent translation done.

Cheers.

Viewing all articles
Browse latest Browse all 4243

Trending Articles