8

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!

Simon Ayzman
  • 247
  • 3
  • 5
  • 12
  • From the User-Agent header. – marekful Aug 02 '18 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 Aug 02 '18 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 company … who are likely bound by non-disclosure agreements. – Quentin Aug 02 '18 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 Aug 02 '18 at 14:34
  • @marekful — Plenty of information is exposed. The display resolution, for instance. – Quentin Aug 02 '18 at 14:35
  • Inconclusive. I can set any display resolution. It won't change my device. – marekful Aug 02 '18 at 14:39
  • @marekful — My point is that there are many bits of data they could use (possibly in combination) to infer the device type. I'm not suggesting that the display resolution is the only one or that it is definitely one. – Quentin Aug 02 '18 at 14:41
  • @Quentin I was hoping there was some exposed API that I could hook into – Simon Ayzman Aug 02 '18 at 14:41
  • 1
    Device category does in fact come 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](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ua) 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 Aug 03 '18 at 00:03
  • @DaImTo Thanks for the input! How close is it to something like this: https://github.com/hgoebl/mobile-detect.js/ – Simon Ayzman Aug 03 '18 at 15:37
  • that looks like over kill IMO you could test it with three lines in a web browser useing the measurement protocol. when I get back from vacation I may have to put up an example – Linda Lawton - DaImTo Aug 04 '18 at 00:21

2 Answers2

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 outcome 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:

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

Max
  • 12,794
  • 30
  • 90
  • 142
  • "It is indeed from the User Agent Header" — Do you have anything to support that? None of the links you reference say it is used to determine if the device is mobile, tablet, or desktop. – Quentin Aug 02 '18 at 14:41
  • 1
    I don't think you will find more details from Google explaining what they use to calculate browser/device because they don't want people messing with it (analogy: you won't find details about which data points are used for SEO, because they don't want people messing with it). The 4 dimensions I listed (`User Agent`, `Screen resolution`, `Java Support`, `Flash version`), are to my knowledge the only 4 that are device-specific from all GA collects (others are derived from them): https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=platform_or_device. – Max Aug 02 '18 at 14:53
0

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.

fattalico
  • 21
  • 1
  • 9
  • Do you have evidence to back that assertion up, or are you speculating? Note that the question did mention user agent headers. – Quentin Aug 02 '18 at 14:33
  • The user-agent string doesn't generally include the device category (I've just double checked by looking at the debug tools in my browser, it makes no mention of "desktop", "tablet" or "mobile") – Quentin Aug 02 '18 at 14:33