Forum Moderators: open

Message Too Old, No Replies

Best ASP/VBScript method for screen resolution tracking

Looking for the most fool-proof solution

         

mattglet

6:39 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm looking to gather ideas about what the best ASP/VBScript solution is to track user screen resolution.

I've used a JavaScript cookie set/ASP cookie read method for years (if ASP can read the cookie, log it into the db). I just started thinking about this code again, wondering if there's a way I haven't thought about that's better. I researched some other methods, and have decided to get some opinions here.

How do YOU do it?

mrMister

12:36 am on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The browser resoluton settings aren't sent in the HTTP request, so it's impossible to read it directly from server side code. You have to read it client side and send it to the server somehow. You're doing it with a cookie, which is probably the best way of doing it.

Easy_Coder

2:58 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



javascript & asp for me too but BrowserHawk has an object that will report the screen size if you want to look at some other way's this is getting accomplished.

Edit: that is one sweet object. I just ran the demo and it gave me back Height, Available Height, Width and Available Width + a crapload of other neato stuff.

Ocean10000

7:10 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Most desktop systems do not report screen resolution directly, unless accessed by javascript. But some mobile devices will report there screen resolution as part of there UserAgent or http headers but the formats how they report this info depends on the mobile device. Also some text based browsers will report there text with and height so you can tailor your html to make it easier for the reader.

Here is little snipit of javascript that I use to detect the users screen resolution.

if(typeof(screen)=="object")
{
sr = screen.width+"x"+screen.height;
ar = screen.availWidth + "x" +screen.availHeight;
cd = screen.colorDepth;
}

mrMister

7:51 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wouldn't bother re-inventing the wheel. There's a great little piece of javascript that comes with awstats (an open source web log report generator) that tracks a number of things...

Screen size
Browser size
Screen color depth
Java enabled
Macromedia Director plugin
Macromedia Shockwave (flash) plugin
Realplayer plugin
QuickTime plugin
Mediaplayer plugin
Acrobat PDF plugin

Just download the .zip file from here...

[awstats.sourceforge.net...]

extract the following file...

/wwwroot/js/awstats_misc_tracker.js

Include it in all your pages and the data will be stored in a cookie which can be accessed via ASP.

Easy_Coder

1:15 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So what happens when the client has js disabled...

mattglet

3:53 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... NO SOUP FOR YOU!

Seriously though... that's kind of what I'm hoping this thread will uncover. BrowserHawk is a good solution, but I'd like to shy away from 3rd party software.

Ocean10000

4:10 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Depending how you have writing your tracking script, when javascript is disabled usually there is no way to get access to the screen data you requested. The most you can do is set a tracker image to return with no data which you can take it as they have javascript disabled etc.. and set a cookie if they allow it.

I know on my sites that I maintain usually the if the javascript is disabled the cookies and referer urls are all block also, and I either take it as an anonymiser/proxie at work removing them, or some other blocking method in place.

Easy_Coder

5:28 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah that's why I threw BrowserHawk out there. Even thought it's 3rd party in my mind it's better then the js solution because it doesn't rely on js. I'm gonna get the trial version and fiddler it to see what the heck is getting passed over in the http header when that thing fires.

mattglet

7:19 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



EC-

If you can figure out how it works, do share... I'd be interested in making my own version.

Ocean10000

9:59 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The last time I used browser hawk (2 or 3 years ago). It used a redirect page that contained javascript and object for flash/acrobat to test if they were present and work. They still use javascript to do most of there work back then I am not so sure now. But I do not see many other ways they can detect the information they need, without javascript enabled, besides the normal useragent string detection.

And for making your own version, its pretty easy there a previous post list awstats javascript tracker code. I made my own to track the items I wanted.

Examples of which are.
1. Screen resolution/actual window size
2. referer (to get a second copy incase the first is blocked)
3. UserLang
4. Javascript Version

Then its just a mater of linking this information to a session via cookie or custom url (depending) on your options.

mrMister

11:00 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah that's why I threw BrowserHawk out there. Even thought it's 3rd party in my mind it's better then the js solution because it doesn't rely on js.

I assume that's some kind of April Fool's day joke?

Browserhawk does rely on Javascript to get the screen resolution too.

Pretty much the only way of getting the screen resolution is through javascript. If the visitor doesn't have javascript enabled, you're not going to get the screen size.

mattglet

3:18 am on Apr 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd be interested in making my own version.

I meant of BrowserHawk ;)

I already have a very successful version of a screen resolution tracker (as noted in my first post). I just wanted to spark conversation to see if anyone had something else they wanted to share.

Easy_Coder

4:13 am on Apr 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume that's some kind of April Fool's day joke?

Wrong...

Browserhawk does rely on Javascript to get the screen resolution too.

Really, how so?

Easy_Coder

12:01 pm on Apr 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mrMister, I think I see how it works now... I really wasn't trying to be a smart arse but I do want to know how it works 'under the hood'.

From a server side object you can spin up Context Objects, I suspect they're doing that to send the js enabled client a page.

mrMister

2:24 pm on Apr 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mrMister, I think I see how it works now...

They're trying to make a profit, so they focus all their marketing towards giving the impression that their product does something that others don't, when in fact it's been done before (usually better) by the open source community.

That's the biggest gripe I have about commercial components, you can't trust them to be honest and open about how their product works and what it does.