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)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With