Getting Screen Dimensions and Depth Information

When analyzing web site traffic, it is often useful to know the screen dimensions (width and height in pixels) and screen depth (depth in bits; i.e. number of available colors) of your visitors, so you can design the width and height of the pages to fit on the monitors of your visitors, and so you can decide what colors to use in your images. This information is not generally available in web server log data, but you can add it by including the following small JavaScript program in one or more of your HTML pages:

<script language="JavaScript">
document.write('<img width="1" height="1" src="/log_analysis_screen_info.gif?' +
 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');

Just copy the script, paste it at the bottom of one of your web pages, and you're done. This script causes an extra entry to be included in the log data for each line processed. The entry, which appears as a hit on the file /log_analysis_screen_info.gif, is used automatically by Sawmill when analyzing web logs to compute the values of the derived "screen dimensions" and "screen depth" log fields, which are displayed in the statistics in the "Top screen dimensions" and "Top screen depths" views.

The image /log_analysis_screen_info.gif does not need to exist, but if it doesn't, you will see 404 errors (broken links) in your statistics for the file, and in some browsers you may see a small dot on your page where the JavaScript code appears. If you don't want to see these, you need to create an image file at the root of your site called /log_analysis_screen_info.gif. A blank or transparent image is a good choice. You can also put the image somewhere else on your site, and change the JavaScript to match, but the name of the image and its parameters must remain the same. However, it will actually slow your page down slightly if the image exists -- it is usually best to not create the image file.