O'Reilly logo

Web Site Measurement Hacks by Eric T. Peterson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #69. Measure Connection Type

Determine whether your visitors use modems or broadband connections, and support critical site design decisions.

One of the most common questions asked of web measurement applications regarding site performance is, "How can I tell how my visitors connect to the Internet when they're coming to my site?" This question gets asked most often when companies are trying to make design decisions about page size, use of multimedia and Flash, and whether or not to deploy weighty tracking code.

High-end geographic reporting

Figure 5-3. High-end geographic reporting

Many web measurement vendors attempt to provide this information using an obscure hack, the fact that IE users self-report how they connect to the Internet, and that this information is available via the JavaScript document object model. You'll commonly see reports called "Connection Type" that provide percentage of visitors using "LAN," "modem," and "unknown" or "other" types of connections (Figure 5-4).

While these reports are moderately useful, especially considering they come with no additional setup hassles, you can use some relatively simple JavaScript to build a much more complete report using custom variables.

The Code

The following code has been written in JavaScript, which is pretty much your only option since it needs to run in the visitor's web browser to test how long it takes to download an image.

The essence of this hack ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required