Device attributes in the data layer
Google Tag Manager for WordPress can add the type and the model of the device your visitor uses into the data layer. Turn on the Device data option in the Browser, OS & device data section of the plugin settings to make these variables available.
This page describes GTM4WP 2.0.0 and newer. Where the legacy 1.x versions of the plugin behaved differently, the older behavior is marked with a bold GTM4WP 1.x: lead-in.
The plugin identifies the device with User-Agent Client Hints, which the browser itself provides. Browsers that do not support Client Hints, currently Safari and Firefox, fall back to reading the user agent string, which gives less detail.
Three details are worth knowing before you build tags on these variables:
- The values arrive in a
gtm4wp.deviceDataevent shortly after the page has loaded, not in the initial data layer object. Tags that read these variables need a Custom Event trigger that listens forgtm4wp.deviceData. - A variable that the browser cannot determine is left out of the event instead of being set to an empty string. Check that the variable exists before you use it in a trigger condition.
- The detection happens in the browser, so the values stay correct on pages that are served from a page cache or a CDN.
GTM4WP 1.x: the device was identified on the server with the bundled WhichBrowser library, using the headers that the browser sent with the request, and the values were part of the data layer object written into the page. The library is no longer bundled with the plugin.
Please make sure that you do not use this data for unethical purposes. Ask for consent from your visitor if you access or process the data in a way that falls under data protection regulations.
Note: you do not need this feature to collect browser, operating system and device data in Google Analytics, which measures all of that on its own. The feature is useful if you want to pass such data to other 3rd party systems, or to limit certain tags in your Google Tag Manager container so that they fire only on specific devices.
The same detection also provides browser attributes and operating system attributes, each with its own checkbox in the plugin settings. If you turn on more than one of the three options, all of the values are delivered in the same gtm4wp.deviceData event.
With the Device data option turned on, you can access the following data layer variables:
deviceType
The type of device your visitor is currently using to browse your website. The value is either desktop or mobile.
Tablets have no value of their own. Client Hints reports whether the browser considers itself a mobile browser rather than what the hardware is, and tablet browsers usually do not set that flag, so a tablet most often reports desktop.
GTM4WP 1.x: WhichBrowser also reported tablet, along with less common types such as television. A trigger that matches tablet no longer fires after the upgrade, so rebuild it on desktop or mobile.
deviceModel
The model name of the device, for example Pixel 7 or Galaxy S20. Client Hints treats the model as detailed information that the browser may withhold, and desktop computers report no model at all, so in practice this variable reaches the data layer on Android devices. Check that it exists before you use it in a trigger condition.
GTM4WP 1.x: the model was parsed from the request headers on the server, so it was also reported on Apple devices.
deviceManufacturer
Legacy 1.x variable. The name of the company that manufactured the device, for example LG, Apple or Samsung. It was usually empty on desktop computers, because browsers do not report the name of the laptop or desktop PC in use. It is not available from GTM4WP 2.0.0, because User-Agent Client Hints do not expose the manufacturer. Where you only need to tell the major platforms apart, osName on the operating system attributes page is the closest substitute.

