Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Script to count # of times a page is viewed
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Script to count # of times a page is viewed

 Post Reply Post Reply Page  12>
Author
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Topic: Script to count # of times a page is viewed
    Posted: 14 January 2010 at 8:39pm
Hello everyone,

I'm looking for a classic ASP-based code / script that counts the number of times a page is viewed. Just like here on the forum when a thread is viewed the # increases every time a user views that topic.

Example: This page has been viewed _______ times.
Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2010 at 7:00pm
Stat Counter http://www.statcounter.com/ will do it
Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2010 at 7:00pm
You can even then edit around that to say
This Page Has Been Viewed (then stat counter code) times Wink
Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2010 at 11:23pm
That uses PHP and that's not what I'm looking for. I'm looking for an ASP-based script because the site I intend to use this on is of classic ASP. 
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2010 at 11:29pm
I found one that accomplishes exactly what i asked for, and here it is if anyone needs it:

http://www.psacake.com/web/iv.asp

**Note: this is not listed on that page but you need to create a count.txt file and grant read/write access to it, for this script to work.


Edited by iSec - 15 January 2010 at 11:50pm
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2010 at 7:07pm
On asp pages, also make sure that pages aren't being viewed from the browser or a proxy cache:

Set:
Response.CacheControl="Private"

This is to prevent proxy servers from caching the page. It's supposed to be the IIS default but some web hosts set it to Public by default to allow caching and reduce load on their servers.

Also set:
Response.ExpiresAbsolute=#January 16,2010 16:00:00#
Set this to the current date/time to ensure that the page expires from the browsers cache as soon as it's viewed.

These two commands change the HTTP headers for the page.
Setting page expiration using HTML meta tags is not reliable across all browsers.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2010 at 12:03am
dpyers, thanks for the tip... i needed that, especially the expiration one Thumbs Up
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2010 at 3:26am
Even changing the http header content sent by the servers isn't 100% reliable. Some ISP's and internet services offering a "faster" internet ignore the http header info as well and run their own cache's to server up pages quicker.

Counter services typically force the retrieval of an image or file from another ip address. often using a variable link. It adds another layer to what would need to be cached to replicate the page without actually retrieving it but large ISP's cache millions of pages/files.

Google has put a lot of pressure on ISP's to respect header info and the problem isn't as acute as it's been in the past.
For most of us, missing a count or two is not a big deal. If it really matters to your site though, a strategy involving http_referer, cookies, remote images, and db updates can eliminate the misses.
You won't see a good return on your investment in time to set it up, but for some sites, accuracy is more critical than for most sites.

On the flip side of the coin, some browsers can preload pages linked to the current page. You make get a hit, but no eyeballs actually viewed the page.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.