Get browser,OS and user agent from request — screenshot of github.com

Get browser,OS and user agent from request

I find `gadget` useful for parsing User-Agent strings. It provides a "common sense" browser and OS name, focusing on the browser engine, which is often more relevant for analytics than hyper-specific versions.

Visit github.com →

Questions & Answers

What is `gadget`?
`gadget` is a Go library designed to parse User-Agent HTTP headers to identify the browser and operating system. It focuses on providing "common sense" names and versions rather than highly specific or rarely useful details.
Who is `gadget` designed for?
`gadget` is designed for developers who need quick and accurate high-level browser and OS information, especially for analytics or usage statistics where identifying the underlying browser engine is more critical than precise browser versions or brand names.
How does `gadget` differ from other User-Agent parsing libraries?
`gadget` distinguishes itself by prioritizing simplicity, performance, and "common sense" results. It aims to identify the browser engine, avoids guessing bot status or mobile type, and skips parsing outdated or unreliable User-Agent patterns, leading to faster processing and more focused data.
When should `gadget` be used?
`gadget` is ideal for applications like web analytics platforms, such as GoatCounter, where the primary need is to understand which browser engines and operating systems users generally employ. It's suitable when detailed, per-patch-version browser data is not required, and performance is a concern.
Can `gadget` shorten User-Agent strings?
Yes, `gadget` includes a `ShortenUA` helper function that can compress User-Agent strings while retaining the ability to `UnshortenUA` them back to their original form, useful for storage or bandwidth optimization.