473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 8896
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: marks542004 | last post by:
Hi, sorry if the title is confusing. I regularly visit a website whicg is a specialist website for custom engineering products. The website puts up a banner ad about specials available from...
3
by: stephenmarron | last post by:
Hi Everyone, I am having trouble looking for a script that will rotate images from a standard text file. I have a folder set up with two images that rotate every time the page is refreshed....
6
by: Michael Landberg | last post by:
Hi I am crewating a website using HTML and Javascript. The website can be seen by everybody that has internet. Do I have to consider that some people don't have javascript enabled in their...
32
by: Ciaran | last post by:
Hi I've seen this a few places - The site lists off the number of people (not logged in) currently browsing the site. How can I do this with php / mySQL please?
3
by: Dev | last post by:
Dear All, i have get combination of four PHP script for count the visitor of website but when i apply all these i have no answer. i am posting the code of all four PHP script below. CODE OF...
9
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. ...
19
by: Ganesh J. Acharya | last post by:
Hi there, I want to redesign my website and make that look professional. I made this about 6 years ago with very little knowledge of internet. Today I am getting about 4000 visitors a day for...
3
by: DavidPr | last post by:
I made a website for a group of people and they want a visitor counter on it. I don't like hit counters because if the site is dead everyone will know it. But, it's their website. I did an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.