MetricRaven

Tracking

What is a user agent string?

Also called: User-Agent header, UA string

A user agent is the text a browser, app or bot sends in the User-Agent header of every request to say what software it is, such as Chrome on Android or Googlebot. Analytics tools read it to count browsers, operating systems and devices, and to filter out bots.

Updated

What a user agent is

Every HTTP request carries a User-Agent header, and scripts can read the same value as navigator.userAgent. Servers use it to pick the right page or file, and analytics use it to report on browsers and devices. Bots send one too, which is how well-behaved crawlers like Googlebot or GPTBot identify themselves.

The format is old and messy. Browsers copied each other's tokens for compatibility, so nearly every browser string starts with Mozilla/5.0 and Chrome's includes Safari. To read one, you look for the most specific token, not the first one.

Example: a user agent, piece by piece

Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/159.0.0.0 Mobile Safari/537.36

PartWhat it says
Mozilla/5.0A compatibility token. Almost every browser sends it.
(Linux; Android 10; K)The platform. Chrome now reports a fixed Android version and K instead of the device model.
AppleWebKit/537.36 (KHTML, like Gecko)The rendering engine, also frozen for compatibility.
Chrome/159.0.0.0The browser and its major version; minor numbers are zeros.
Mobile Safari/537.36Mobile marks a phone; Safari is another compatibility token.

This is Chrome's reduced user agent. Since the reduction, sites that need the exact device or version have to ask for User-Agent Client Hints, which the browser sends in Sec-CH-UA-* headers. Paste any string into the user agent parser to see how it breaks down.

How to use user agents in analytics

  1. Group by browser, operating system and device type rather than by the raw string. There are thousands of variants of the same browser.
  2. Treat the user agent as a claim. Anyone can send any string, so a bot that matters (a search crawler, say) should be verified by IP range too.
  3. Filter obvious automation: empty user agents, curl, python-requests, headless browsers and known crawlers.
  4. Don't use the user agent alone to identify people. Thousands of visitors share the same string.

Common mistakes

  • Matching Safari to find Safari. Chrome and Edge include it too. Check for the more specific tokens first.
  • Trusting the version number after the reduction. Minor versions and device models are frozen.
  • Believing a bot is who it says it is. A scraper can claim to be Googlebot; only an IP check proves it.
  • Counting bot visits as people. Unfiltered crawlers and headless browsers inflate visitors and push down conversion rate and bounce rate comparisons.

How MetricRaven uses user agents

  • Browser, OS and device. A small built-in parser turns each user agent into a browser (Chrome, Safari, Edge, Firefox, Samsung Internet, Opera…), an operating system and a device type (desktop, mobile or tablet). Reports show those, not the raw string.
  • Bots are dropped. Pageviews whose user agent is empty or contains bot, crawl, spider, headless, curl, wget, python-requests and similar tokens are ignored. The script also skips automated browsers (webdriver, HeadlessChrome, Puppeteer, Playwright, Selenium).
  • Fakes are rejected. A desktop Chrome far behind the current release, or a user agent that disagrees with the browser's own client hints, is treated as a scraper rotating user agents.
  • Data-center traffic from cloud and hosting networks is excluded by default (bot traffic settings).
  • Cookieless visitor IDs. Without consent, the visitor ID is a keyed hash of the day, site, IP and user agent. Nothing is stored in the browser and the ID changes daily (consent).
  • Crawlers are tracked separately. Most bots never run the script; the @metricraven/ai-crawl package reports them from your server, matched by user agent and checked against published IP ranges (Bots & AI crawlers).

Questions

Why do all user agents start with Mozilla?
For compatibility. Sites once served better pages to browsers that announced themselves as Mozilla, so other browsers copied the token, and it has stayed in nearly every browser's string.
Can a user agent identify a person?
Not on its own, since many people share the same browser string. Combined with other data such as the IP address it narrows things down, which is why privacy-focused analytics hash it and never store it as an identifier.
How do I find my user agent?
Open your browser's developer console and run navigator.userAgent, or paste the string from any server log into a user agent parser to see the browser, OS and device it describes.
What are User-Agent Client Hints?
Headers such as Sec-CH-UA that Chromium browsers send so servers can ask for details, like the full version or device model, that the reduced user agent string no longer includes.
Full glossary

Count people, not bots

MetricRaven parses every user agent into browser, OS and device, drops bots and fake browsers before they reach your reports, and tracks crawlers on their own.

14-day free trial, no card required.