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.

Community
  • 1
  • 1
karthick
  • 5,998
  • 12
  • 52
  • 90

1 Answers1

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.

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47