0

I am working on web analytics, I have to find out the os of the visitor specific with following conditions

1.Cross-browser compatibility.

2.For all devices(tablet,iphone,mobile,deskstop,etc).

3.Maximum possible accuracy.

I have referred some questions regarding os detection, Answer is navigator.platform but it does not supported for some devices

Note: we cannot rely on useragent as well.

Any suggestion will be greatful.

2
  • what about to mix navigator.platform and navigator.userAgent to fallback if .platform returns null or undefined? Commented May 8, 2013 at 16:16
  • @alexi May be tats is the final workaround if i didn't get any solution. Commented May 9, 2013 at 4:51

1 Answer 1

0

In case it could be PHP instead of JavaScript; this piece of code is so reliable and accurate and have been tested on many devices -mobile devices- and it works like charm:

preg_match("/(android|avantgo|blackberry|nokia|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);

this only detects mobile devices but you can tweak the code in different way to get what you need.

Also check this link >> php to detect browser and operating system - which contains PHP codes too.

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.