Storing user device types
Example of storing custom device type data using tags.
Last updated
Was this helpful?
Example of storing custom device type data using tags.
Last updated
Was this helpful?
Was this helpful?
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.
You should include this script tag after the included UXWizz tracking snippet.
<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>