Forum Moderators: coopster

Message Too Old, No Replies

Building my own Web Stats

Have Some Questions

         

wfernley

2:04 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone.

I am trying to build my own web stats program for my site in PHP and so far it is going good. I was curious about a few things though.

Currently, I can record thir REMOTE_ADDR, REQUEST_URI, HTTP_HOST and PHP_SELF (kinda same as REQUEST_URI). I was curious if their was any other information I could grab from the user. I mainly want to see what site they came from and what keywords they used if it was a SE. I doubt I can do that thouh, except for looking at my logs, which are incomplete (Hate my hosting company).

I am also curious about Search Engine Bots. I woudl like it so they don't add to my counter. Is there a way to identify these? I have been looking on the other forums here but really haven't found anything solid on this subject. Are there a list of IP's for Google Bots and I could just restrict those IP's from adding to my counter?

Thanks for your help :)

Wes

uncle_bob

2:11 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



I would guess one of the most important values to capture is the referer, so you know where they came from, whether it was from a search engine, directory or link on another site.

wfernley

2:18 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tried getting the referrer. I can't remember what the $_SERVER variable was sorry, but when I tried to get it, the value was blank. Could my hosting company not allow the referrer to be visible. I can find it in the logs though.

Salsa

2:41 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



Try sticking this in your script to see what you've got:

?><pre><? echo "\$GLOBALS ="; print_r($GLOBALS);?></pre><?

mincklerstraat

3:09 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Salsa's got the key here; echo $_SERVER; will usually just give you Array. What you want is $_SERVER['HTTP_REFERER']. It often doesn't show since if there's no referer, it isn't set (I believe). Just going directly to a phpinfo page or outputting it from a page you get to by typing it in the address bar isn't likely to show it.

jatar_k

8:51 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



grab $_SERVER['HTTP_USER_AGENT'] too

coopster

9:19 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



We recently threw a *superglobal* script into the latest Bag o' Tricks [webmasterworld.com] thread that may come in handy. Run it on your server to see what variables might be available.

Don't forget, as mentioned here, that not all $_SERVER variables are available or trustworthy. There is a link to the PHP manual pages in the script that has much more information.