# Storing user device types

If you want more granular device type data to be stored (e.g. mobile/tablet/desktop or Android/iOS/Windows/MacOS) and used to filter sessions, you can manually store extra device data for each session using [Tags](/api/tags.md).

{% hint style="info" %}
Note: The device type is sometimes hard to define, for example nowadays laptops can have a touchscreen or tablets can have keyboards and mouse and be used as laptops, the so called 2-in-1 devices (e.g. Microsoft Surface).
{% endhint %}

You should include this script tag **after** the included UXWizz tracking snippet.

{% code title="Store device type as tag" %}

```html
<script>
(function() {
// Generic function to get device type based on UA string
function deviceType() {
    const ua = navigator.userAgent;
    if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) {
        return "tablet";
    }
    else if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(ua)) {
        return "mobile";
    }
    return "desktop";
};

// Store the device type as a tag, e.g. "device-mobile"
UST.addTag('device-' + deviceType());
})();
</script>
```

{% endcode %}

{% hint style="info" %}
By default UXWizz does store the device type in the `ust_clients` table under the `device-type` column, but only stores `0` for desktop devices and `1` for mobile devices (no difference is made for tablets).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uxwizz.com/useful-examples/storing-user-device-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
