469,286 Members | 2,500 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Website visit counter in JavaScript

Hello,

can anyone send me a link or even some sample of script that counts visits
to a website ?

Thanks,

TomCat


Jul 23 '05 #1
11 8351
In article <d5**********@sunce.iskon.hr>, op*******@mail.inet.hr enlightened
us with...
Hello,

can anyone send me a link or even some sample of script that counts visits
to a website ?


This is not commonly implemented with client-side script for a variety of
reasons.
Why do you want that?

Google page counters to find tons of the things, free and otherwise.

--
--
~kaeli~
Cthulhu saves our souls and redeems them for valuable
coupons later.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
TomCat wrote:
can anyone send me a link or even some sample of script that counts
visits to a website ?


No. A visible website counter serves no purpose, not even the intended
purpose of counting visitors. It can count downloads, not visitors, if
that (consider proxies and client-side caches). Get a proper access log
evaluation tool, installed server-side, and most certainly not implemented
with server-side JS.
PointedEars
Jul 23 '05 #3
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:19****************@PointedEars.de...
TomCat wrote:
can anyone send me a link or even some sample of script that counts
visits to a website ?


No. A visible website counter serves no purpose, not even the intended
purpose of counting visitors. It can count downloads, not visitors, if
that (consider proxies and client-side caches). Get a proper access log
evaluation tool, installed server-side, and most certainly not implemented
with server-side JS.


Actually, a visible website counter CAN count unique visitors, based on IP
address. It's not perfect, but neither are many access logs, for the same
reasons.

I have some personal sites that are hosted on my ISP, which doesn't support
any server-side processing. When I want a hit counter, I use a free
hit-counter service like www.amazingcounters.com (or google "free hit
counter") - they're server-side - the service's server: you add them to
your page by simply inserting an <img> tag.

Downside to free counters - they're advertiser-driven, so you have to have
the ad link on your counter. No big deal for the stuff that I was counting -
It's up to the OP to decide if that's acceptable.
Jul 23 '05 #4
Tony wrote:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
TomCat wrote:
can anyone send me a link or even some sample of script that counts
visits to a website ?
No. A visible website counter serves no purpose, not even the intended
purpose of counting visitors. It can count downloads, not visitors, if
that (consider proxies and client-side caches). Get a proper access log
evaluation tool, installed server-side, and most certainly not
implemented with server-side JS.


Actually, a visible website counter CAN count unique visitors, based on IP
address.


No, it cannot. Even if not connected via a proxy (which would
be the IP address logged), a computer is a machine that needs
not to be used by only one person at a time.

Visible Web site counters in fact serve no purpose but posing
(or the opposite, depending on the counter value at visit) but
they introduce several problems:

1. they increase network load and bandwidth usage (unnecessarily)
2. they waste computing time and increase server load
3. they slow down document rendering, especially on
intensive server load (continue with 2.)

Thus are not used by any professional commercial Web site.
You may want to use Google to find that my opinion is not
that uncommon among reasonable/professional Web authors.
It's not perfect, but neither are many access logs, for the same
reasons.


Logs can at least provide statistically evaluatable information
about specific resource access. Nothing more can be determined
reliably if not requested in a representative strawpoll; that
includes used browser, languages aso.
PointedEars
Jul 23 '05 #5
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:18****************@PointedEars.de...
Tony wrote:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
TomCat wrote:
can anyone send me a link or even some sample of script that counts
visits to a website ?

No. A visible website counter serves no purpose, not even the intended
purpose of counting visitors. It can count downloads, not visitors, if
that (consider proxies and client-side caches). Get a proper access log
evaluation tool, installed server-side, and most certainly not
implemented with server-side JS.
Actually, a visible website counter CAN count unique visitors, based on
IP
address.


No, it cannot. Even if not connected via a proxy (which would
be the IP address logged), a computer is a machine that needs
not to be used by only one person at a time.


But that is still more significant than simple hits/downloads, as you said.

Also, the same IP address can be used for more than one computer, if they're
dynamically allocated.
PLUS, one user could be using more than one computer at different locations,
thus one user has two unique visits logged.

They're not perfect, but they can do more than just counting the number of
times a page is downloaded.
Visible Web site counters in fact serve no purpose but posing
(or the opposite, depending on the counter value at visit) but
they introduce several problems:

1. they increase network load and bandwidth usage (unnecessarily)
2. they waste computing time and increase server load
3. they slow down document rendering, especially on
intensive server load (continue with 2.)

Thus are not used by any professional commercial Web site.
I didn't get the impression this was for a professional, commercial web
site.
You may want to use Google to find that my opinion is not
that uncommon among reasonable/professional Web authors.
It's not perfect, but neither are many access logs, for the same
reasons.


Logs can at least provide statistically evaluatable information
about specific resource access. Nothing more can be determined
reliably if not requested in a representative strawpoll; that
includes used browser, languages aso.


Unless you use persistent cookies or some other similar means to identify
each visitor, you can't get much more info about who, uniquely, visits your
site. And even such methods have their drawbacks, given that (once again)
more than one user can use the same computer, a user can delete their
cookies, etc.
Proper tool for the proper job. I have a couple simple sites that I just
want to be able to get an idea how much it's being visited. A hit counter is
fine for that. I have no need for access logs for such pages.

A high-volume commercial website is another matter entirely, and would be
handled as such.

I mean, you wouldn't use a bulldozer to dig a hole to plant flowers in,
would you?
Jul 23 '05 #6
In article <11*************@corp.supernews.com>, so*****@somewhere.not says...
Proper tool for the proper job. I have a couple simple sites that I just
want to be able to get an idea how much it's being visited. A hit counter is
fine for that. I have no need for access logs for such pages.

Get yourself one of the hundreds of free counters and save yourself
the time and headaches.
Jul 23 '05 #7
Tony wrote:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
Tony wrote:
Actually, a visible website counter CAN count unique visitors,
based on IP address.
No, it cannot. Even if not connected via a proxy (which would
be the IP address logged), a computer is a machine that needs
not to be used by only one person at a time.


But that is still more significant than simple hits/downloads,
as you said.


I did nothing of the kind.
Also, the same IP address can be used for more than one computer, if
they're dynamically allocated.
Yes, of course.
PLUS, one user could be using more than one computer at different
locations, thus one user has two unique visits logged.

They're not perfect, but they can do more than just counting the
number of times a page is downloaded.
So your argument is:

"Yes, my bike having rectangular wheels is not easily rided and most of the
time it is borken, yet it works quite well if it sometimes happens that
there are rectangular-shaped holes in the street."

Great core dump!
Visible Web site counters in fact serve no purpose but posing
(or the opposite, depending on the counter value at visit) but
they introduce several problems:

1. they increase network load and bandwidth usage (unnecessarily)
2. they waste computing time and increase server load
3. they slow down document rendering, especially on
intensive server load (continue with 2.)

Thus are not used by any professional commercial Web site.


I didn't get the impression this was for a professional, commercial web
site.


The point is that features not used on professional commercial Web sites
but largely on newbie private Web sites indicate low-quality features.
Nobody reasonable makes business with people who obviously do not
understand their business and the needs of their customers.
You may want to use Google to find that my opinion is not
that uncommon among reasonable/professional Web authors.
It's not perfect, but neither are many access logs, for the same
reasons.


Logs can at least provide statistically evaluatable information
about specific resource access. Nothing more can be determined
reliably if not requested in a representative strawpoll; that
includes used browser, languages aso.


Unless you use persistent cookies or some other similar means to identify
each visitor,


There is no such thing as a persistent cookie. Cookie management is up
to the user.
you can't get much more info about who, uniquely, visits your site. And
even such methods have their drawbacks, given that (once again) more than
one user can use the same computer, a user can delete their cookies, etc.
Yes, just as I wrote, thanks for confirmation. It is neither desirable
nor possible to evaluate anything other than specific resource access and
so having the chance to review the concept of the Web site based on a
reliable statistical basis.
Proper tool for the proper job.
Web counters are not tools, they are an (increasing) annoyance.
I have a couple simple sites that I just want to be able to get
an idea how much it's being visited. A hit counter is fine for that.
No, it is not, for the reasons already presented.
I have no need for access logs for such pages.
Your problem if you only have one home page you want to edit based on bogus
data you collect by annoying visitors. I maintain Web sites (consisting of
several documents) where I need reliable information about without annoying
visitors (because, among others, that would bias the collected data).
[...]


PointedEars
Jul 23 '05 #8
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:17****************@PointedEars.de...
They're not perfect, but they can do more than just counting the
number of times a page is downloaded.
So your argument is:

"Yes, my bike having rectangular wheels is not easily rided and most of
the
time it is borken, yet it works quite well if it sometimes happens that
there are rectangular-shaped holes in the street."


No, my argument is that it's pointless for someone running a small personal
or hobby site to resort to full-blown logging.
I didn't get the impression this was for a professional, commercial web
site.


The point is that features not used on professional commercial Web sites
but largely on newbie private Web sites indicate low-quality features.
Nobody reasonable makes business with people who obviously do not
understand their business and the needs of their customers.


Good point. I wouldn't "make" business with someone who tried to sell me a
Ferrari when a Geo Metro suits my needs.

The first aspect of good business is to understand your customers needs -
NOT to sell them what you prefer. Just because full-blown logging systems
are good for some businesses doesn't mean that they're even appropriate for
other applications.

Do you disagree with that?
Proper tool for the proper job.


Web counters are not tools, they are an (increasing) annoyance.
I have a couple simple sites that I just want to be able to get
an idea how much it's being visited. A hit counter is fine for that.


No, it is not, for the reasons already presented.
I have no need for access logs for such pages.


Your problem if you only have one home page you want to edit based on
bogus
data you collect by annoying visitors.


I see, so my personal site with pictures of my kids, that I want to get a
ROUGH idea how many different people check it out, and how often it's
visited, should use a full-blown logging system instead of a simple hit
counter?
I maintain Web sites (consisting of
several documents) where I need reliable information about without
annoying
visitors (because, among others, that would bias the collected data).


And you are assuming that I don't?

Jul 23 '05 #9
"Tony" schrieb:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
They're not perfect, but they can do more than just counting the
number of times a page is downloaded.
So your argument is:

"Yes, my bike having rectangular wheels is not easily rided and
most of the time it is borken, yet it works quite well if it
sometimes happens that there are rectangular-shaped holes in the
street."


No, my argument is that it's pointless for someone running a small
personal or hobby site to resort to full-blown logging.


That logging does not need to be "full-blown" (whatever you want to
imply with that), it can be reduced to what is needed and still provide
reliable unbiased data, i.e. which document has been accessed when and,
following from that, how often it has been accessed within a certain
span of time.

<http://httpd.apache.org/docs-2.0/logs.html>
I didn't get the impression this was for a professional,
commercial web site.


The point is that features not used on professional commercial Web
sites but largely on newbie private Web sites indicate low-quality
features. Nobody reasonable makes business with people who
obviously do not understand their business and the needs of their
customers.


Good point. I wouldn't "make" business with someone who tried to
sell me a Ferrari when a Geo Metro suits my needs.


Exactly.
The first aspect of good business is to understand your customers
needs - NOT to sell them what you prefer. Just because full-blown
logging systems are good for some businesses doesn't mean that
they're even appropriate for other applications.

Do you disagree with that?


Yes. You have a misconception about who is the customer here.
Hint: it is _not_ the author/Web master.
Proper tool for the proper job.


Web counters are not tools, they are an (increasing) annoyance.
I have a couple simple sites that I just want to be able to get
an idea how much it's being visited. A hit counter is fine for
that.


No, it is not, for the reasons already presented.
I have no need for access logs for such pages.


Your problem if you only have one home page you want to edit based
on bogus
data you collect by annoying visitors.


I see, so my personal site with pictures of my kids, that I want to
get a ROUGH idea how many different people check it out, and how
often it's visited, should use a full-blown logging system instead
of a simple hit counter?


As I said, a) your data is biased for several reasons (including the
until now not mentioned fact that client-side script support and image
support can be disabled or not even present) and so can *not* even
provide a rough idea of what you seek to determine. Instead, it
additionally annoys visitors. b) Logging can be easily configured.

Now what would be the more reasonable approach, provided that you want
to attract *more* visitors rather than less?
I maintain Web sites (consisting of several documents) where I need
reliable information about without annoying visitors (because, among
others, that would bias the collected data).


And you are assuming that I don't?


Well, if you maintain at least one Web site not constisting of only a
single document you would need to add an annoying counter to every
document for an supposed-to-be equal result and still collect biased
data.

But, since Web counter back ends are not implemented using client-side
scripting and seldom, if ever, using server-side JS, I suggest we either
continue discussion elsewhere (comp.infosystems.www.authoring.misc?) or
end it.
PointedEars
Jul 23 '05 #10
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:42***********************@newsread2.arcor-online.net...
I see, so my personal site with pictures of my kids, that I want to
get a ROUGH idea how many different people check it out, and how
often it's visited, should use a full-blown logging system instead
of a simple hit counter?
As I said, a) your data is biased for several reasons (including the
until now not mentioned fact that client-side script support and image
support can be disabled or not even present) and so can *not* even
provide a rough idea of what you seek to determine. Instead, it
additionally annoys visitors. b) Logging can be easily configured.


First, in regard to b) - NO IT CAN'T. On my personal pages, which are
supplied free by my ISP, there is no logging service, and there is no
server-side scripting. It's straight HTML and client-side scripting.

as for a) - if it were that important of a site, it wouldn't be on my
personal pages.
Now what would be the more reasonable approach, provided that you want
to attract *more* visitors rather than less?


Frankly, it doesn't matter on my PERSONAL PAGES with PICTURES OF MY KIDS for
the family to look at, does it?


Jul 23 '05 #11
Thomas 'PointedEars' Lahn wrote:
"Tony" schrieb:

"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
They're not perfect, but they can do more than just counting the
number of times a page is downloaded.

So your argument is:

"Yes, my bike having rectangular wheels is not easily rided and
most of the time it is borken, yet it works quite well if it
sometimes happens that there are rectangular-shaped holes in the
street."


No, my argument is that it's pointless for someone running a small
personal or hobby site to resort to full-blown logging.

That logging does not need to be "full-blown" (whatever you want to
imply with that), it can be reduced to what is needed and still provide
reliable unbiased data, i.e. which document has been accessed when and,
following from that, how often it has been accessed within a certain
span of time.


No it can't. It can only tell you that data about the *server*. It can
not tell you how many times it was retrieved from a proxy/cache which
makes the logs just as un/reliable as hit counters.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by marks542004 | last post: by
3 posts views Thread by stephenmarron | last post: by
6 posts views Thread by Michael Landberg | last post: by
32 posts views Thread by Ciaran | last post: by
3 posts views Thread by Dev | last post: by
9 posts views Thread by Pygmalion | last post: by
19 posts views Thread by Ganesh J. Acharya | last post: by
3 posts views Thread by DavidPr | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.