Browser attributes in the data layer
Google Tag Manager for WordPress can add the name and version of the browser your visitor uses into the data layer. Turn on the Browser 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 browser 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 browser 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 in specific browsers.
The same detection also provides operating system attributes and device 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 Browser data option turned on, you can access the following data layer variables:
browserName
The name of the browser your visitor is currently using to view your site. On Chromium based browsers the value is the brand name that Client Hints reports, for example Google Chrome, Microsoft Edge or Opera, so it is safer to use a contains match than an equals match in your trigger conditions. Where the user agent string is used instead, the plugin recognizes Firefox, Microsoft Edge, Opera, Chrome and Safari.
GTM4WP 1.x: WhichBrowser reported a shorter name, for example Chrome instead of Google Chrome. Review your trigger conditions after the upgrade if they match this variable exactly.
browserVersion
The version number of the browser. Chromium based browsers report the full version, including minor and build numbers, for example 48.0.2564.103 (this is an earlier Chrome version number). If the browser declines the request for the detailed version, only the major version number is available, for example 48. In Safari and Firefox the version is read from the user agent string, which reports fewer digits.
GTM4WP 1.x: the full version number was always available, because it was parsed from the request headers on the server and did not depend on what the browser was willing to share.
browserEngineName
Legacy 1.x variable. The name of the engine the browser used to render the webpage, mostly Blink for Chrome users and Gecko for Firefox users. It is not available from GTM4WP 2.0.0, because User-Agent Client Hints do not expose the rendering engine. If you still need it, build a lookup table variable in Google Tag Manager that maps browserName to an engine name.
browserEngineVersion
Legacy 1.x variable. The version of the engine the browser used to render the webpage. It is not available from GTM4WP 2.0.0 and it has no replacement, because User-Agent Client Hints do not expose the version of the rendering engine.

