how can we get the no of hits of our site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

how can we get the no of hits of our site

Post by djdon11 »

Hi friends ..

i want to know that how we can show the no. of visits of our sites means how many times our site has been visited by users , i want to show this numbers in the title bar ....
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

Statscounter.com is a free counter,
With some tweaking you can get the javascript in your heading too.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

I believe by logging every hit in a database. If you need to log only unique hits you should compare the client IP.

@thiscatis this counter does not give the stats as PHP value.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:I believe by logging every hit in a database. If you need to log only unique hits you should compare the client IP.
... Or, more reliably, create a session.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Count them.. analyze your access logs... there's a myriad of ways.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

superdezign wrote:
miro_igov wrote:I believe by logging every hit in a database. If you need to log only unique hits you should compare the client IP.
... Or, more reliably, create a session.
Sessions are much unreliable than IPs. It is simpler to delete cookies than change ip.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

miro_igov wrote:
superdezign wrote:
miro_igov wrote:I believe by logging every hit in a database. If you need to log only unique hits you should compare the client IP.
... Or, more reliably, create a session.
Sessions are much unreliable than IPs. It is simpler to delete cookies than change ip.
Why would anyone want to delete a cookie? it is not something you will benefit like breach security or something. And IPs can legally change on each request.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Imagine some of these sites who webmasters enter their links and people vote. If the uniqueness of the visit is kept in cookie guess the benefit.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

miro_igov wrote:Imagine some of these sites who webmasters enter their links and people vote. If the uniqueness of the visit is kept in cookie guess the benefit.
not sure I understand what you mean...session is used to create unique visit...not counting on each refresh of page.
Of course that might not be the goal...
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

jmut wrote:session is used to create unique visit..
Totally wrong. What happens when you delete your cookies? Session is destroyed. What will cause another visit? Increment the counter (another unique visit).

Maybe you do not know that session identifier is client-side attribute and could be manipulated?
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

And here we come to my first comment. why would anyone want to change/manipulate such data? It is not any security risk and client will not get any real benefit of faking unique visits.

Just don't tell me unique visits are better implemented based on IP address.
Cause in case of cookie it should be intentional while with using ip address...it can be wrong without intention.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

@miro_igov The use of IP addresses as an identifier for users is unreliable. Your argument that sessions are less reliable isn't a correct one. Users can restart a session, but the user likely will not, especially if the site has any sort of user system. Secondly, the only real invalid data you'd get from the use of sessions is that there are users that do not have cookies enabled. Those users would not be counted.

What would you do for user's who have blocked their IP from you, or who's IP changes per-request? It isn't an issue of opinion, but of practicality. Basing a hit counter on uniqueness can never be totally accurate, as we can't force users to identify themselves as such. It's a matter of using a method that is most likely to return near-accurate results.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

jmut wrote:And here we come to my first comment. why would anyone want to change/manipulate such data? It is not any security risk and client will not get any real benefit of faking unique visits.

Just don't tell me unique visits are better implemented based on IP address.
Cause in case of cookie it should be intentional while with using ip address...it can be wrong without intention.
Did you read about the site ranking service i posted above? If the site rating is based on sessions user will abuse the results voting 1000 times, that is the benefit of manipulating cookies.

@Superdizi "who have blocked their IP from you" are you talking about proxies? Is this not a method of uniques - no one will abuse with the same proxy IP if it's already used.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:@Superdizi "who have blocked their IP from you" are you talking about proxies? Is this not a method of uniques - no one will abuse with the same proxy IP if it's already used.
That's hardly the issue. The real problem is not counting users multiple times as opposed to users that don't get counted at all.
User avatar
The Phoenix
Forum Contributor
Posts: 294
Joined: Fri Oct 06, 2006 8:12 pm

Post by The Phoenix »

Please, PLEASE read Analog's explanation of how the web works. It tells you everything you need to know about what you can (and more importantly, what you cannot) reliably measure.

At best, you can reliably measure the number of requests. There are a huge number of tools for doing so (including analog), and numerous php based free/open solutions.

Hope that helps.
Post Reply