Analytics for mobile vs. desktop traffic

We have an analytics platform for our clients to understand where people are interacting with our extension.

We’d like to be able to break this down by mobile vs. desktop.

As we don’t have access to the window object, we can’t reliably tell if a user is on mobile or not. What alternatives are there for determining desktop vs. mobile usage? It doesn’t look like many of the options described by MDN here would work?

Two questions:

  1. Is there an official Shopify recommended way of achieving this?
  2. In the absence of the window object, while it’s imprecise, is it safe to assume that the navigator.userAgent is accessible? Is this known to be reliable enough for a best guess? Or could this be removed in the future?

Hi @edhgoose

Using navigator.userAgent would the only supported method for an extension to differentiate being rendered on mobile vs desktop currently.

Thanks @Liam-Shopify - and to confirm, is that the officially recommended/supported way, or does that work at the moment but there’s no guarantees around support?

That is the the method that our product team has recommended - as far as I know there’s no plan to remove support for this.