Archive: Statistics
May 1, 2008
Server-side Google Analytics
Peter van der Graaf did a little analysis of the URLs that are generated by the Google Analytics Javascript API and put together a very useful tutorial for building Analytics-enabled applications without the use of Javascript.
When you look at the analytics javascript code you see that it combines several sets of data into an image request. This image request sends the right data to Google (not the javascript). When you know what url you should use for the image, you can call the image directly and send the same data. Of course you need to be able to request the image url and that isn't easy from another image, rss feed or pdf. This is why we request it "server side".
You can add the code to the PHP that drives a blog site, for instance, and generate page views when your RSS feed is hit. You can even write a very simple script to proxy images and downloads, which will let you track hit data for all files on your site, not just the html pages viewed by a javascript enabled browser.
Taken a step further, you could even use this on the client side, triggering analytics views from standalone Flash apps or even desktop applications.
The one thing you need to keep in mind is that server-side analytics requests will appear to come from your server, not the client's machine. So while you can track page views and download events this way, you'll loose a lot of the information about your user base. Because of this, it would probably make sense to use a separate tracking ID for the server side events.
Google Analytics Without Javascript
Posted by Jason Striegel |
May 1, 2008 08:27 PM
Google, PHP, Statistics, Web, Web Site Measurement |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 11, 2008
Automatic outbound link analytics with jQuery
I had the challenge of adding Google Analytics tracking code to all the outbound links on a site I've been working on. There are hundreds of these links scattered around the site, so rather than try and edit a bunch of links, manually adding onclick handlers in an error-prone fashion, I decided to get lazy and write some code to handle it for me.
First I was thinking about doing some sort of regular expression search and replace throughout the site and database, but that reminded me of CSS3 selectors and their ability to do simple pattern matching. I've seen people apply a special style to outbound links this way, so after a few minutes of monkeying around with things, I now have a chunk of jQuery that will automatically track clicks on all outbound links.
Here it is, in a nutshell:
jQuery(function($){
// Match all anchor tags in the "maincontent" div with
// urls that begin with "http" but don't contain the
// string "yourwebsite.com"
$('#maincontent a[href^="http"]').not('a[href*="yourwebsite.com"]').click(function(){
try {
// Get the href url and toss out the "http://"
var href = $(this).attr('href');
if ( href.indexOf("://") > 0 ) {
// Track the page in Google Analytics as
// "/tracking/outbound/www.somesite.com/foo"
var outbound = '/tracking/outbound/' + href.split("://",2)[1];
pageTracker._trackPageview(outbound);
}
} catch( e ) {}
}
}
With this running, all of my internal pages get tracked as usual, and any external links will appear as pageviews that look like "/tracking/outbound/www.somesite.com/foo".
If you link out to many different pages on several sites, keeping the full site url in the tracking code and building these deep paths is particularly useful. Google Analytics will allow you to drill down into the tree like it was normal content and quickly pull numbers on how many total outbound clicks you received (/tracking/outbound), how many went to www.somesite.com (/tracking/outbound/www.somesite.com), and how many people clicked out to a particular page on the site.
This saved me quite a bit of time and is immensely more flexible than any other outbound tracking method I've used. I hope this helps someone else. Drop me a line in the comments if this works out for you.
Update: it looks like I wasn't the first to do this. An article by Rebecca Murphey shows how to do something similar, while also adding the referring post title to the tracking code. Pretty cool stuff, I must say.
Posted by Jason Striegel |
Apr 11, 2008 10:57 PM
Ajax, Google, Statistics, Web, Web Site Measurement |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
January 31, 2008
R: open source statistical computing

I was digging around for an open source statistics package today and came across R, a GPLed statistics and and data analysis suite. Sweet!
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.One of R's strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.
So I've been messing around with this for the last half hour and it's really an exciting package, especially if you're a coder or unix geek. You interface with R through a command line programming interface, executing simple statements, setting variables, and defining functions. It feels similar to issuing commands at a unix prompt, except you're working with data sets instead of file descriptors.
What's cool is the robust capability of the standard function set. Want to read in a data set from a tab delimited table you found on the internet? Check this out:
# Read a table in from a URL (tab delimited table with row headers)
Mydata <- read.table(http://someserver.com/table.txt', header=TRUE)
# Display summary (mean, median, min, max, etc.) for each column
summary(Mydata)
# Get the standard deviation for the values in column "foo"
attach(Mydata)
sd(foo)
Learning the command set is a little daunting at first, but the console even does tab completion. If you don't know what a function does, just put a question mark before it. For instance, "?sd" will quickly pull up help for the standard deviation function.
I've only scratched the surface, but there are links below to some R beginner guides which should help you get started. Anyone out there more familiar with the package? Please share any useful links and tips in the comments.
The R Project for Statistical Computing - Link
An Introduction to Statistical Computing in R - Link
Producing Simple Graphs with R - Link
Posted by Jason Striegel |
Jan 31, 2008 08:35 PM
Math, Science, Statistics |
Permalink
| Comments (6)
| TrackBack
| Digg It
| Tag w/del.icio.us
June 14, 2007
Graph your Flickr pageviews with Statr

Ever want to track how many folks are viewing your photos on Flickr? Just give Statr access to pull your pageviews and it will collect and graph your Flickr statistics for you.
Statr for Flickr allows you to track and plot page views statistics for your Flickr account. Graphs are automatically updated on a daily basis and can be linked from external websites.
Statr for Flickr: tracking page views for your Flickr account - [via] Link
Posted by Jason Striegel |
Jun 14, 2007 12:57 PM
Flickr, Statistics, Web |
Permalink
| Comments (1)
| TrackBack
| Digg It
| Tag w/del.icio.us
May 26, 2007
Gapminder: world statistics over time

Gapminder is an interactive utility for examining world statistics. It's extremely cool if you're curious about things like the relationship between income and life expectancy or carbon emissions and internet use. There is a scrubber for adjusting the date, so you can see how the data points have changed over time.
I wonder if internet use per capita will someday be negatively correlated with carbon emissions (ie. people working from home).
Posted by Jason Striegel |
May 26, 2007 08:08 PM
Statistics |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
April 9, 2007
HOW TO: Coding a Statistical Spellcheck

Have you ever been curious about how some applications, such as MS Word or Google, can return spelling suggestions so quickly and accurately?
Chances are, they are using a fairly straightforward probabilistic model, trained on a sample dictionary of common words and phrases, to determine when a word has been misspelled and to suggest the most likely alternate spelling. With a little effort and a small amount of code, you can add similar functionality to your own applications!
"Let's get right to it. I figured that in less than a plane flight, and in less than a page of code, I could write a spelling corrector that achieves 80 or 90% accuracy at a rate of at least 10 words per second. And in fact, here, in 20 lines of Python 2.5 code, is the complete spelling corrector" -Link.
Related:
Posted by Jason Striegel |
Apr 9, 2007 08:28 PM
Statistics |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
February 19, 2007
Internet weather forecast accuracy

Ever wonder which internet weather site was the most accurate? OmniNerd breaks it down... -
Weather forecasting is a secure and popular online presence, which is understandable. The weather affects most everyone's life, and the Internet can provide information on just about any location at any hour of the day or night. But how accurate is this information? How much can we trust it? Perhaps it is just my skeptical nature (or maybe the seeming unpredictability of nature), but I've never put much weight into weather forecasts - especially those made more than three days in advance. That skepticism progressed to a new high in the Summer of 2004, but I have only now done the research necessary to test the accuracy of online weather forecasts. First the story, then the data.
OmniNerd - Articles: Internet Weather Forecast Accuracy - [via] Link.
Posted by Phillip Torrone |
Feb 19, 2007 02:33 AM
Outdoor, Statistics |
Permalink
| Comments (0)
| TrackBack
| Digg It
| Tag w/del.icio.us
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- AppleTV
- Astronomy
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Design
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
Recent Posts
- Update the hacker map
- HOWTO - embed fonts from a SWF into a Flex app
- Server-side Google Analytics
- Remember before you forget, but no sooner.
- Stop XSS attacks with SafeHTML
- Improving astronomical video using VirtualDub
- DIY 7x5 LED scroller
- iPhone LoJack - location tracking for your iPhone
- Simple bike computer from scratch
- Open GPS Tracker
www.flickr.com
|





Recent comments