1

Have I missed any obvious things that you can log to keep track on your visitors (using PHP and JavaScript)?

  • Can I get computer name?
  • Can I get the country?
  • Can I get the city?
  • Postal code?
  • Any other information that can be collected from certain browsers?

PHP DOCUMENT :

<script>

<?php 
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);?>
<?php echo "document.write('The IP-adress: ' + " . "'" . $ip . "'" . " + '<br>');";?>
<?php echo "document.write('The host address: ' + " . "'" . $hostaddress . "'" . " + '<br>');";?>

document.write('The date: ' + new Date() + '<br>');
document.write('Get the entire URL of the current page: ' + location.href + '<br>');
document.write('This document was last modified on:' + document.lastModified + '<br>'); // good to know wich version of the page they have

if (document.referrer != ''){
document.write('The referrer of this document is: ' + document.referrer + '<br>')
}
else{
document.write('The is no referrer.<br>')
}

document.write('Number of URLs in history list: ' + history.length + '<br>')

// I know it doesn't allways return the right browser info, but it gives a good clue.
document.write("Browser name: " + navigator.appName + '<br>');
document.write("Browser version info: " + navigator.appVersion + '<br>');
document.write("Platform: " + navigator.platform + '<br>');
document.write("User-agent header sent: " + navigator.userAgent + '<br>');
document.write("Language of user: " + navigator.userLanguage);

document.write("Total Height: " + screen.height + '<br>');
document.write("Total Width: " + screen.width + '<br>');

document.write("Cookie: " + document.cookie + '<br>');

</script>
7
  • 4
    Note; keep in mind nearly everything is spoof-able. Commented Nov 13, 2011 at 23:59
  • You can get country and possibly city from the ip address, after scraping data from an ip address lookup site. Commented Nov 14, 2011 at 0:00
  • Thanks for the tip bozdoz! Are there any free ip address lookups (nice companies that doesn't do bad things with the ip-adresses i am checking...)? Commented Nov 14, 2011 at 0:07
  • Bracketworks, what do you mean with spoof-able? That visitor can pretent to be someone else? Commented Nov 14, 2011 at 0:08
  • Anyone can pretend to be someone else. Commented Nov 14, 2011 at 0:33

1 Answer 1

1

There are a lot of geolocation databases available. If you wish to go free there are some free databases too with less frequent updates than their paid counterparts, e.g. MaxMind GeoLite.

For more Google for IP geolocation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.