最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does Google Analytics determine “Device Category” (mobiletabletdesktop)? - Stack Overflow

programmeradmin0浏览0评论

Currently, Google Analytics for web exposes a device category field, the discrete values for which are mobile, tablet, and desktop. The interface also allows you to dig deeper into the specific device it is. I imagine that Google has some kind of dictionary that maps these values to each other (device to device category, and/or vice versa), but I don’t know for sure.

Ultimately, I’d like to hook into this logic and utilize it. I’d like to run experiments based on the device category (i.e., mobile devices, in my case). There are lots of answers out there attempting to determine device category based on user agent and the like, but Google seems to have the most accurate eye into this. Thank you for your thoughts, in advance!

Currently, Google Analytics for web exposes a device category field, the discrete values for which are mobile, tablet, and desktop. The interface also allows you to dig deeper into the specific device it is. I imagine that Google has some kind of dictionary that maps these values to each other (device to device category, and/or vice versa), but I don’t know for sure.

Ultimately, I’d like to hook into this logic and utilize it. I’d like to run experiments based on the device category (i.e., mobile devices, in my case). There are lots of answers out there attempting to determine device category based on user agent and the like, but Google seems to have the most accurate eye into this. Thank you for your thoughts, in advance!

Share Improve this question asked Aug 2, 2018 at 14:26 Simon AyzmanSimon Ayzman 2573 gold badges5 silver badges12 bronze badges 11
  • From the User-Agent header. – marekful Commented Aug 2, 2018 at 14:27
  • 1 @marekful — Do you have evidence to back that up, or are you speculating? Note that the question did mention user agent headers. – Quentin Commented Aug 2, 2018 at 14:30
  • @Simon Ayzman — Questions of the form "How does this specific proprietary system do X?" are not a good fit for StackOverflow. In general, they are unanswerable except by people who work for the pany … who are likely bound by non-disclosure agreements. – Quentin Commented Aug 2, 2018 at 14:31
  • By default, no other information is exposed that can be used to guess platform. Since Google needs a generic solution (i.e. they can't ask everyone to send extra info in requests), this must be it. Speculation. – marekful Commented Aug 2, 2018 at 14:34
  • 1 Device category does in fact e from the user agent and if you dont believe the knowledgeable people who have answered your question i suggest you try using the measurement protocol directly and test it yourself user agent I have been a Google developer expert for Google analytics since 2014 and i am telling you as well. Not everything needs to be documented. – Linda Lawton - DaImTo Commented Aug 3, 2018 at 0:03
 |  Show 6 more ments

2 Answers 2

Reset to default 1

It is indeed from the User Agent Header which Google then analyzes to determine device, OS, and browser versions. Some things to point out:

  • The processing is done on the server side (Google) so there is no way of directly modifying that data (even when sending data via the measurement protocol).

  • The processing details are not disclosed by Google so you won't know what the oute of your experiments are until they're reported by Google Analytics (which due to the 24-48 hour data processing latency might make such experimentation tedious).

  • Attempting to manipulate it might "break" your analytics: Google is vague about this, they just say: "Google has libraries to identify real user agents. Hand crafting your own agent could break at any time". 2 consequences I can think of: Google simply drops the traffic if it can't parse the User Agent OR marks it as bot/spider traffic (which will also be dropped if you have enabled the bot filtering option).

Although it's not mentioned in the documentation, I also suspect Google to rely on other data points, which could be:

  • Screen resolution
  • Java Support
  • Flash version

Although over time the last one should be less and less relevant as support for progressively disappears.

The device category is obtained from information contained in the browsers 'user agent' string. This is essentially a software that is acting on behalf of a user.

发布评论

评论列表(0)

  1. 暂无评论