Google analytics does good job at monitoring pages visited, but what about pages that are not found on your server and thus never displayed? You can get these pages by moving the content around, having errors in your links, getting malformed links from various webmasters (often they are caused by bad software on their side or miscommunication) or for other reasons. Even a soft like wordpress does not check comment links, which might generate 404 errors (page not found). How to detect such links? Well, you have 3 choices, each of them have their own drawbacks.
2. Log analysis. That is the best method if you have access to log files and you can process them. I prefer using Awstats for that, however you can do it by hand for smaller sites on apache, as errors are logged to separate file as well. The single problem with manual analysis is that error log has less information than common log. There is no referrer link mentioned in the error log. However, this can be solved by using grep to scan access log for 404 error codes as well. The drawback is that some CMS processes all requests and do not generate error codes successfully. This means that you will not see such errors in logs even if they exist.
3. If you can’t access error logs, the best way of action is to use custom error pages and create a log from them. You have to log both referrer path and request uri for best result. This approach can be implemented in many of the abovementioned CMS’es too.
So, what to do with bad links? This depends on what causes these links. If it is an advertisement campaign or a referrer site, you will have to create a redirect from bad link to the appropriate good one. In cases this is a malformed comment link, I would just delete it from database.