Forum Moderators: open

Message Too Old, No Replies

Monitor Resolution - how do I track it?

How to add stats on site visitors' screen resolutions to web logs?

         

rach77

1:51 pm on Nov 30, 2004 (gmt 0)

10+ Year Member



Hi all,

I've got a couple of stats from the usual suspects on the current dominant browser resolutions (i.e. 800x600 still very significant, but - depending on which stats you look at - no longer the leader).

However, I've trawled around and still can't find the answer to this - how, exactly, do I go about retrieving stats on what *my* site's visitors are using, so I can assess the potential impact of a width redesign? I've come across loads of scripts and packages that include this as part of a full analytics pack, but nothing that *just* sets things up so I can collect this kind of data routinely.

Any tips would be very gratefully received.

Many thanks,

Rachael

AWildman

5:17 pm on Nov 30, 2004 (gmt 0)

10+ Year Member



I don't know how much you know about perl and js, but you could add a piece of js into one or more of your site(s)'s most visited pages which writes out calls a perl script to write out an image. In so doing, you can pass the screen height and width dimensions as parameters to the perl script. We do this to gather our users' screen sizes.

We do it like so:
IN HTML
<script>
document.write('<img src="/scripts/screen.pl?dn=domainname&w=' + screen.width + '&h=' + screen.height + '" width="1" height="1">');
</script>

PERL SCRIPT
use CGI;

$¦ = 1;

&Main();

$¦ = 0;

sub Main {
my ($query);
my ($data);
my ($domain);

$query = new CGI;

$domain = &taintCheckSub($query->param('dn'));

if ($domain ne 'yoursitesdomainname')
{print "Location: h*tp://www.yourdomainname.com/images/dot.gif\n\n";}

$data = $domain . "\t" . localtime($^T) . "\t" . $query->param('w') . "\t" . $query->param('h');

&logAppendSub ("/pathtologfile/screen.log", $data);

print "Location: h*tp://www.$domain.com/images/dot.gif\n\n";

return 1;
}

1;

Obviously, you'll have a little work to do yet, but this works very nicely for us.

[edited by: BlobFisk at 10:16 am (utc) on Dec. 1, 2004]
[edit reason] Delinked example URLs [/edit]

jollymcfats

5:21 am on Dec 1, 2004 (gmt 0)

10+ Year Member



You can also use AWildman's technique with an existing, static image:

<script>
document.write('<img src="/someimage.gif?w=' + screen.width + '&h=' + screen.height + '">');
</script>

The trick here is that the web server ignores query parameters supplied to images. But the query does end up in the access log, so you can collect the data after the fact. Your existing log analysis tool might even do the stat work you want, since each distinct screen resolution will seem to have a different URL in the log.