User-Agent Strings and Mobile Device Detection Solutions
What exactly is a user-agent string?
Within the context of the HTTP protocol, a user-agent
is simply a string passed in the User-Agent
request header that is used as a means to identify
itself. User-Agents are most notably used by web
browsers, web crawlers and mobile devices. For more information check out RFC 1945.
An example of the user-agent for an iphone is…
Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0_1 like Mac
OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko)
Version/3.1.1 Mobile/5B108 Safari/525.20
To see what your current user-agent go to www.useragentstring.com.
How are user-agent strings used?
The most common use of user-agent strings is to tailor
the response for a given piece of content based upon what
the user-agent is representing. For example if you
wanted to serve up a mobile friendly version of a web
page, you could detect if the user-agent matches a
specific pattern or user-agent. This detection can be as
simple as looking for a specific user-agent string if you
only wanted to target an iphone or a droid or as complex
as utilizing a third party device detection provider to
serve up content for nearly any mobile device.
Device Detection Solutions
There are several popular third party device detection
providers, depending upon what level of accuracy you
require and how much money you are willing to spend will
ultimately determine how accurate your device detection
will be.
Device Atlas – High cost, but highly
accurate. DeviceAtlas has an easy to use API for
accessing their user-agent database and can be used with
nearly any programming language.
Mobile Device Browser File – Free,
but ASP.NET only. Not as accurate and is no longer
supported after October 29, 2010.
WURFL – Open
source solution that seems to have a large following and
great support. If you don’t have the money to fork up
for DeviceAtlas this is your best bet.
In closing…
User-agent strings are pretty simple to understand, however detecting them and figuring out exactly what the ua string represents is another thing. This is why companies like DeviceAtlas exist, because it is no menial task to keep up with the ever growing number of user-agent strings. Because of this not any one solution is going to be 100% accurate, which is why it is not a bad idea to use multiple sources to detect your user-agents.
.matti