Blog: Tracking

Google Analytics on a USB Stick with Drupal
engineer

How To Get Detailed Metrics for Drupal Site Running on USB Drives

How To Get Detailed Metrics for Drupal Site Running on USB Drives

We recently put a disaster relief kit in the form of a Drupal website on a usb drive for the American Institute of Architects’ Communities by Design initiative (for details, see here, here, and here). As development proceeded, we got to discussing setting up the Drupal installation to “phone home” to get software updates and centralized backups. And if the installations were already phoning home, well, why not track how and where they are being used?

Using Google Analytics, we developed a tracking mechanism for each and every copy of Drupal on a stick. In this post I’ll describe how we did it.

We decided we wanted to track the stick’s usage – the application pages they visited and length of stay – whenever users were connected to the internet. Google Analytics fit the bill as the best means of tracking, but how would users call Google's javascripts? Google doesn't allow listing 127.0.0.1 or localhost as a domain for purposes of their tracking tools. We solved this problem by embedding an IFrame element in page.tpl.php of the application’s custom theme and listed its source a newly purchased domain. We'll use http://example.com for the purposes of this post so as to keep our tracking domain untainted with spider traffic.