0

How can a website detect the smartphone model of a device that requests a webpage? Google Analytics can get that information as you can see in the image below:

enter image description here

I found this: http://blog.mobileesp.com/?p=177 but only a few phones are recognized by this script. I am looking for an PHP or Javascript solution

JGrinon
  • 1,453
  • 1
  • 14
  • 36
Peter
  • 1
  • 1
  • 1

2 Answers2

0

From Javascript you can read this property navigator.userAgent and PHP $_SERVER['HTTP_USER_AGENT'] both return you the browser version .

alejandro
  • 2,799
  • 1
  • 17
  • 25
  • I am not looking for browser version, but for the mobile type. Like HTC One, HTC Windows Phone 8s et cetera. But thank you for your fast reply – Peter Jan 28 '14 at 21:24
0

In my experience, the best method for detecting mobile/tablet is to use the PHP mobile_detect class which is updated regularly as new devices are released. Unfortunately, I don't know if it provides a way to get the different device types.

User agent parsing is the method you'll have to use, and if mobile_detect doesn't have it, it ought to at least give you a good starting point on how it's done.

Mordred
  • 3,734
  • 3
  • 36
  • 55