Is it possible to use Google Analytics to keep track of when users receive 404, 401, and other types of errors as well as associate additional data with those reports, such as stack traces?
I’ve researched around, and Google Analytics suggests using the following to track when users receive 404 errors:
pageTracker._trackPageview("/404.html?page=" +
document.location.pathname +
document.location.search + "&from=" +
document.referrer);
This is great for keeping track of hits, but it doesn’t really help in tracking down how the user got to the page in the first place. Is it possible to associate more informative data with the page view such as a stack trace? Or is Google Analytics not meant to keep track of such data?
Mind you you will receive some the way you mentioned – mostly the referring page of the 404.
Concerning your other points: there are major security concerns about embedding stack traces into pages shown to the user (which must be the case, because the GA API is client-size JS). It compromises your architecture and other vital security information.
Error logging should be done by a server-side language and basically every language has one, so take your pick – which is probably why GA does not have anything of the kind of features you are asking for.