The advice you read about using feature detection and not browser detection is absolutely right that if you are thinking of using the browser detection to make the site work differently in different browsers (or try to make it work the same).
But there are, as you've said, perfectly legitimate reasons for wanting to record the browser information.
The most obvious answer to this is to use the User Agent string. This is a string that the browser sends as part of the HTTP headers to identify itself.
All requests made to your site will be logged in your server logs. This will include the User Agent string that the browser provided.
There are a number of good analytics products available that can process the server logs and produce statistics on the browsers being used, pages being accessed, and a lot of other data. This is what I would recommend for you. If you go down this route, there is no need for you to do any extra code at all; it is purely a case of using an existing tool to read the logs. You can read about several possible tools for this job here: http://en.wikipedia.org/wiki/List_of_web_analytics_software
The one thing to bear in mind here is that the User Agent string is known not be a fully reliable source of information. It is provided by the browser, and can thus be changed by the user. Some browsers allow users to change them to anything they like. Some will pretend to be other browsers or other browser versions. And some are blanked out entirely by proxies, etc.
However, it's probably about as good as it gets.
It is theoretically possible to pin down more accurate details about the users' browsers using some sneaky Javascript tricks, but it is complex and likely to run foul of malware detectors, so I'd avoid going down that route. Just stick with the User Agent string in the server logs, and you'll be fine.
hope that hepls.