Page 1 of 1

How much site visitor info can I collect?

Posted: Sun Mar 04, 2007 11:48 am
by fatman
I currently collect IP, Browser and date/time info on every visitor to my site for my stats.

Code: Select all

// Check if the referer is your site if not then add record 
 if (preg_match ("/www.holidaypropertyrentalportugal.org/i", "$HTTP_REFERER")) { 
    mysql_close($connection); 
} else { 

// If you cant resolve domain use IP address 
if ($REMOTE_HOST == "") { 
    $host = $REMOTE_ADDR; 
} else { 
    $host = $REMOTE_HOST; 
} 

if ($host == '67.15.16.30') // Kill link something
{} else {
if( empty( $HTTP_REFERER ) or '' == $HTTP_REFERER ) { 
    $HTTP_REFERER = 'No Referer'; 
} 
$file2 = basename($PHP_SELF);

mysql_query ("INSERT INTO myStats (browser, date, host, referer, page, control_date) VALUES ('$browser','$date','$host','$HTTP_REFERER','$file2','$control_date' )"); 
}
Can I collect more usefull info?

I have seen sites (e.g. Blogs) take my name from my PC and use it to welcome me even though I have not entered it.

How is this done, and is there any way to collect info like location, language and email?

This info would be great for compiling demographics on my visitors. :?:

Posted: Sun Mar 04, 2007 6:22 pm
by Buddha443556
There's all kind of information you can track. This is the code I use for IPs:

Code: Select all

	if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) === true) {
	
		if(isset($_SERVER['HTTP_CLIENT_IP']) === true) {
			$_SESSION['session_proxy_ip'] = $_SERVER['HTTP_CLIENT_IP'];
		} else {
			$_SESSION['session_proxy_ip'] = $_SERVER['REMOTE_ADDR'];
		}
		
		$_SESSION['session_ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
		
	} else{
		
		if(isset($_SERVER['HTTP_CLIENT_IP']) === true) {
			$_SESSION['session_ip'] = $_SERVER['HTTP_CLIENT_IP'];
		} else {
			$_SESSION['session_ip'] = $_SERVER['REMOTE_ADDR'];
		}
		
	}
Google Analytics tracks: Browser Versions, Platform Versions, Screen Resolutions, Screen Colors, Languages, Java Enabled, Flash Version, Connection Speed, and Hostnames. Of course, much of their tracking is done client-side.
I have seen sites (e.g. Blogs) take my name from my PC and use it to welcome me even though I have not entered it.
That sounds like OpenID or maybe something you would see on a large Blogger network (that you gave such information to).
How is this done, and is there any way to collect info like location, language and email?
For location, there GeoIP. For language, the HTTP request header Accept-Language.