Jump to content

Browser, System, User stats and demographs..


monkeytooth

Recommended Posts

Hey all whats up lets see if anyone can help me or point me in the right direction on this.

 

Im trying to make my own little custom app for a bulk of my sites. I know there are premade scripts for this stuff but Im not interested in the premade, well the lazy side of me is.. but that said.. I have been trying to google around looking to find out what the full scope of what php can get me as far as browser types and system info I can get from a visitor on my site, and outside of the norm is there any other general info I can obtain about a user who visits the site that may be of use?

 

Does anyone have a generalize or full on list of what info I can obtain.. and if its outside the norm, how about i can go about using php to obtain such info.. Its nothing malisious its mostly cause I am working on a site for one of the unglorious 50 united states.. and it has been made known that the main site I am working on they want any and all possible statistics.. demographs.. what ever you wanna call it I dont knowwhy they would want to know anything and everything but they do.. lol, so any help would be greatly appreciated..

PHP Isn't too good at collecting demographics (bar things like IP, user agent string [which people can change...])

I'd look into using javascript along with xmlhttprequest to post data back to your server (with a lot of error checking, seen as people can also post nonsense data to that page). Javascript will allow you to detect user resolution etc, whereas PHP won't.

Java and Javascript are two completely different things.

Javascript is really your only option for things like screen resolution, as that information is never passed to the server, so PHP can't access it. For things like IP, OS and what browser they're using, php is fine :)

Would you have any examples of Javasccript/Java that would get me extra info? Or any good refrences that I can read through.. Im not to well versed with java/javascript.. as I said i try to when and if possible avoid the use, as people could simply turn it off and negate the use of its being there..

Firstly, it's Javascript. Make sure to get Java out of your head or you'll get quite confused when using google..

 

As for the simplest way to detect a user's screen resolution and post it back to a server using javascript:

 


var sWidth = screen.width;
var sHeight = screen.height;

var xmlhttp=false;

/* Try IE */
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
}

/* Try firefox */
if (!xmlhttp) {
try {
	xmlhttp = new XMLHttpRequest();
} catch (e) {
	xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
	xmlhttp = window.createRequest();
} catch (e) {
	xmlhttp=false;
}
}

if (xmlhttp){
var data = "w=" + sWidth + "&h=" + sHeight;
xmlhttp.open("POST", "page-on-server.php", true); 
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
xmlhttp.send(data);
}

 

Personally, I use jQuery for all my javascript now. It's so much nicer than using the original code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.