How to find broken links?

Find internal broken links with Hextrakt

It requires lots of hard work, time and money to get visitors, publish quality content and rank high in search engine results pages. You certainly don’t want your efforts to be rewarded with 404 pages. Broken links need to be fixed as soon as possible because they impact users and bots in a negative way. Fortunately, this common issue can be spotted easily when crawling a website, which is the best way to detect and fix internal links.

  1. Crawl
  2. Open Linking > Linking issues report.
  3. Show all broken links in the table by clicking Broken outlinks “XX rows”

Linking issues report

Broken links report
Broken links report

You can export source and target URLs to excel to correct links and mark them when fixed (or give it to your developer).

Fix internal linking problems

When moving or renaming a URL, most of the time you will set up a 301 (permanent) redirect, so that bots and visitors can access the new page. Remember that such a redirection is for visitors coming from external domains (clicking on a link), and for bots to index the new page: you still have to correct ALL your internal links.

Ideally, when crawling a website, you should not find 301 or 404 status code URLs. If you do, it means that some links need to be fixed to point to the right final target.

We recommend you create a custom 404 page. You also need to check if the server sends a correct 404 status code when a page does not exist. Design a user-friendly 404 page to retain the visitor and give him another chance to find what he was looking for.

What about broken backlinks ?

This issue occurs when an external link (from another domain) points to your website and the target page does not exist or has been moved. This results in a bad user experience and no link juice (popularity) from the source page.

Find broken backlinks with Google Search Console

Go to “Crawl > Crawl errors report”:

404 errors in Google Search Console
404 errors in Google Search Console

This list of 404 URLs is not exhaustive. You can get the referrers (in this case the pages where Googlebot found the link pointing to your site) by clicking on each URL, in the “Linked from” tab:

Get the referrers for 404 pages
Get the referrers for 404 pages

Find broken backlinks with Google analytics

With Google analytics (or other web analytics tools, like Piwik) you can get the URL of the requested page (which does not exist on the server) and the referrer, so that it will be easy to fix. You can also see how 404 pages affect users (exits). To achieve this, you can create a virtual page view or trigger an event (with non-interaction parameter set to true).

Most of the time you have a custom 404 template (in a WordPress theme there is usually a 404.php file), so you simply add a custom tracking code in the template.

If you don’t have a dedicated template for your 404 pages, you will need to set up a condition to execute the tracking code, e.g. get the title tag and check if it is “404 not found” (that’s an example).

Without Google Tag Manager

In the 404 template, customize your analytics tracking code this way:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');
ga('send', {
hitType: 'event',
eventCategory: '404',
eventAction: window.location.pathname + window.location.search,
eventLabel: document.referrer,
noninteraction: true
});
</script>

With Google Tag Manager

Add this code to your 404 template:

<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event' : '404'
});
</script>

And configure a Universal Analytics event tag:

404 event in GTM
404 event in GTM

Then, set the custom GTM event “404” (coming from the dataLayer) to trigger this analytics tag.

This kind of report you will see in Google Analytics:

404 pages in Google analytics
404 pages and referrers in Google analytics

If there are lots of rows you can export the report to excel and filter the data to only get external links. You can now ask the website owners to link to the right page. When you can’t do this, you can set up a 301 redirect.

If you’re sitting waiting for every single 404, an option is to create an alert in Google Analytics to be notified by email when this event occurs.