Javascript Voodoo: Tracking Downloads, Part 1
This is part 1 of a three part series: [ Part 2 | Part 3 ]
At Pando, our primary goal at the moment is to get our app into the hands of all of the people that need it. Because it solves an increasingly common problem (”how do I send these big files around?”), that’s a lot of people. One measure of this goal, obviously, is tracking how many people download our software (others include successful installations, which recently hit 1 million). Tracking this number turns out to be harder than you think, especially if you want to integrate the count into various analytic packages.
When I arrived on the scene, we were tracking downloads with a script that recorded each download in a custom database table and we were using the open-source, fun-to-pronounce pphlogger package. pphlogger is a solid tool providing the essential stats. And, in true open-source tradition, it’s got an interface only its progenitor* could love. Unfortunately, our simple database counter and pphlogger stats lived in different worlds and couldn’t inform each other; not that they’d know what to say if we hooked them up.
We then decided to try Google Analytics (formerly Urchin, now provided free by Google) which is an impressive tool. The interface is slick and it gathered stats we didn’t even know we wanted till we saw them. And it provided a handy little trick we could use for tracking downloads directly with our other stats.
Most stats trackers these days use javascript “bugs” that slurp up bits of information each time a page loads and bundles it off to the analysis software. When a user clicks on a link to a file, they never actually load a web page, so the javascript bug never gets run and that click doesn’t get stored. Google’s simple trick is to add a function to the onClick attribute of the link and to add a “page view” for a fake URL whenever a user clicks this link. e.g.,
<a href="SomeFileYouWant.exe"
onClick="javascript:urchinTracker('/files/SomeFileYouWant.exe');">Click here to download</a>
I wish more systems used this workaround (I’m looking at you, phpAdsNew). I’ll explain why in Part 2.
Now that Google Analytics knows about download clicks, you can use it’s “conversion tracker” to test things like “how many people got to the download page but never actually clicked to download.” (If that number ever starts going up after you change the page, you have a problem). This can get much more complex (e.g., tracking ad performance/conversions), but it’s nice just to have your stats all in one place. Which brings me to Part 2…
* progenitor: An ancestor is a parent or (recursively) the parent of an ancestor. So this includes a father or mother, as well as grandparents, great-grandparents, and so on. (I didn’t even know I knew this word till I just wrote it down. My brain surprises me sometimes.
