ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Storing statistics --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
310 active users
1750 visitors today
2625 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

The Footer script

First, the following code was added to the Footer() function in utils/Footer.asp.

Out ( '<script language="JavaScript" type="text/javascript">' );
   Out ( 'var sWidth = \'?width=\' + screen.width;' );
   Out ( 'var sRefer = \'&refer=\' + document.referrer;' );
   Out ( 'var sURL = \'&url=\' + document.URL;' );

   Out ( 'document.write(\'<img src="StatCounter.asp\' + sWidth + sRefer + sURL + \'" width=1 height=1 border=0 alt="">\' );' );
Out ( '</script>' );

// now for those brain dead browsers that don't support
// JavaScript, or who have it turned off
Out ( '<noscript><img src="StatCounter.asp" width=1 height=1 border=0 alt=""></noscript>' );

After the <script> statement, which marks the start of the client-side script, I store some information that the browser freely provides.

There is much more information than this, but it very quickly gets untidy dealing with IE/NS/Opera differences. This was all I needed anyway.

The "document.write" statement outputs the contents to the browser as if it was originally part of the HTML stream - it's just an <img> tag with my data passed in the URL. Note that instead of an gif or jpg being referenced, the URL points to an asp file!

Lastly, I use the <noscript> tag to output the <img> normally, without any extra information.

Part 3: The StatCounter.asp "image"...

Featured sponsor
My favorite resources

Selling products online - read how James does it now


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!