Detecting device brand

One library that parses this out for you is Platform.js, and you can use it either client-side or server-side as described in their intro page linked above.

Here's a client-side example:

    <script type='text/javascript' src='platform.js'></script>
    <script type='text/javascript'>
        alert('you are using ' + platform.description + ' on an ' + (platform.manufacturer || 'unknown vendor') )
    </script>

Note that you will get no manufacturer on generic browsers but should get the brand on mobile devices e.g. Apple, Samsung, etc.


You can't do it directly; the userAgent field simply does not contain the vendor. However you can build up a library of userAgent tokens which map to particular vendors. This will involve a lot of research and testing on a wide range of devices, though.

For example, anything with "iOS", "iPhone" or "iPad" in the userAgent you can safely map to "Apple". Then the Samsung Galaxy S3, for example, has the model number in the userAgent, which is "GT-I9300". You can then map this to "Samsung". ...and then you'd need to repeat this for every other device you want to recognise. Looking up user agent strings online is probably the quickest way.