Finding device type for user tracking / analytics script

Finding device type for user tracking / analytics script

My e-commerce store is using a service for retargeting and PPC automation. The service needs me to send the device type of the customer, the options being: Desktop, Tablet, or Mobile.

So I'm trying to find the most accurate way to get this information with a low performance impact and minimal side effects. Most of the solutions I've seen involve:

  1. Checking for screen size with media queries
  2. Using RegExp to target user-agents

Checking media queries seems like a quick and simple solution, but I don't like this for several reasons. These will be a moving Target as devices change over the years, and device size seems like a visual attribute rather than a technical one.

User-agents (might be the wrong term I'm using, sorry on mobile) seems like a better fit but again, this is an even faster moving Target and a large pool of targets to hit.

I've seen a few NPM modules that attempt to solve this problem but they are either outdated or have side effects like adding the device type as a class to the body of the document.

Thanks for any ideas!

Submitted August 13, 2017 at 04:56AM by Likemercy
via reddit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s