Finding and fixing broken links on your site is one of the easiest ways to immediately and directly improve your visitors’ experience. There are plenty of link checker tools out there, but they are mostly overpriced and don't work that well.
With Google Analytics you can find these broken links easily. The best part is that no changes to the GA code need to be made and that GA gives you additional information, so you can calculate lost traffic and know which links should be fixed first.
So how do you do it?
To track error pages you will need to add the Google Analytics Tracking Code (GATC) to your error page template(s). Without the tracking code on the error pages you will not be able report on these pages or find their associated broken links. As a reminder, here is the code:
With the GATC on your error pages they will now be tracked as page views. Since these error pages will be considered page views you will want to create a filter that will allow you to view them in isolation from each other.
In the Top Content report, use the “Filter” box at the bottom to filter pages to those containing “404.”
For this example, the 404 error page is /site/404/index.php. Click that URL to view the Content Detail page. Next, click the Navigation Summary link in the right hand column of the page to get more detailed information about the page like so:
The “Previous Pages” are pages on your site containing broken internal links. Go to each of these pages on your live site and click on your links until you find the link that doesn’t work. Now you can begin fixing.
You can see that when visitors reached the example error page, 61.73% of them exited the site altogether. When these broken links are fixed, the experience of about 50 visits will be improved and users will be engaged on the site for a longer amount of time.
What if you want to find broken links to your site from external sites? Wouldn’t you want to let them know to fix the link?
In our example above, the 72.15% “Entrances” mean that visitors either mistyped the URL, or that a link to your site from another referring site is wrong.
To investigate, you can create an Advanced Segment. To do this, click on Advanced Segments in the top right corner of the GA interface and then click “Create a new advanced segment.” Click “Content” in the left column and drag and drop “Page” into the empty Dimension or Metric box, as shown below. Choose the condition “Contains” and make the value your 404 URL.
Click “Save and Apply to Report” and then view your Referring Sites report. Here you’ll get a good idea of sites linking to yours that could contain a broken link. This will not be 100% accurate, as it will include visitors who reached the site through a link that worked and then chanced on clicking a broken link within the site. If a site stands out, though, like the top one in the image with 15 visits, it’s worth investigating.