Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting device brand

I am working on web analytics. I am using JavaScript client-side and NodeJS server-side. I know we can find out device type using userAgent, but how do I detect the device brand (client or server side)?

like image 931
karthick Avatar asked May 03 '13 10:05

karthick


1 Answers

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.

like image 170
explunit Avatar answered Oct 07 '22 00:10

explunit