I’ll say this upfront… broken internal links are bad. They’re bad for SEO and they’re bad for the experience your visitors have so it’s important to find them and fix them. In this post I’m going to show you how to find broken links in Google Analytics so you can:
- Identify pages or posts which include a broken link that someone has clicked.
- Clean up any broken links you find.
Internal broken links can occasionally occur without you realizing and so you should check your blog for them on a regular basis. Consequently, I’ll show you how to set up an alert to let you know when Google Analytics finds internal links that don’t work.
In order to use this you’ll need to have a Google Analytics account with tracking code added to your blog.
Identifying Internal Broken Links in Google Analytics
It’s reasonably straightforward to find broken links in Google Analytics, but the first thing you need to do is understand how your blog generates a 404 “page not found” error page, and more specifically the title that page has.
You can do this by finding a page on your blog that you know doesn’t exist. So… go to your blog and visit a URL like this:
N.B. Substitute example.com with your domain, followed by “/zxzxzxzxzxzx”.
Unless you have inadvertently created a page URL like the one above, you should see a 404 error (page not found). We are going to look for the page title of this page since we’ll need this when we go to Google Analytics.
And… here’s how to find your 404 error page title.
Hover your mouse cursor (mouse arrow) over the tab in your browser for the “zxzxzxzxzxzx” error page and keep it there.
After a second or two your page title will appear. You can see in the image above that my page not found title is imaginatively called… “Page not found – SideGains”!
The next thing we’re going to do is create a custom report in Google Analytics to focus upon this page title.
Creating a Custom Report in Google Analytics to Find Internal Broken Links
The first step in creating a custom report is to click the Customisation > Custom Reports option in you Google Analytics account.
The Custom Reports area is a place where you can create very sophisticated reports based upon your data and the way you want to see it. You can create highly useful reports based on your specific needs, over and above the default reports Google Analytics presents out of the box.
In this case we’re going to create a custom report to show us where someone has clicked an internal broken link that Google Analytics has tracked. Then do the following…
- Click the “+ New Custom Report” button to set up a new report.
- Make the report type “Flat Table”.
- Choose Previous Page, Page and Page Title as your dimensions.
- Use Unique Pageviews as the metric.
- Remember the “page not found” page title? We’re going to use this here to filter for 404 error pages. So include a “regex” filter for your page not found page title (you can see my example below).
- We also need to create another filter to exclude page not found errors that have come from external visits to a missing page on your blog. You need to set up an exact match filter here for the phrase “(entrance)”. This ensures the report only tracks broken links on your blog.
When you’ve done this your GA Custom Report should look like this:
Give your report a Title and Name (I’ve chosen Broken Internal Links and 404 Page Not Found Errors from Internal Links) and click save.
Drumroll… this is the result for me…
What Does the Broken Links Custom Report Show?
The custom report we’ve created shows:
- Previous Page Path: This represents the page where the broken link was clicked.
- Page: This is the page the visitor attempted to reach… i.e. the URL we know doesn’t exist!
- Page Title: The title of the 404 error page.
- Unique Pageviews: The number of times the broken link was clicked.
N.B. The leading “/” in the Previous Page Path and Page columns represents everything after your domain url (in my case https://www.sidegains.com). Hence the “/” on it’s own in the Previous Page Path column represents my homepage.
Bear in mind that this is a custom report showing internal broken links clicked by visitors that Google Analytics has tracked. It’s important to understand that Google Analytics doesn’t find all the broken internal links on your blog. It can only report on the broken links someone has clicked. If you want to find all your internal broken links, you’ll need to use a tool that spiders your blog looking for 404 errors.
Future Proofing Yourself Against Broken Links With Google Analytics Custom Alerts
So we now have a report that shows broken links in Google Analytics… but it would be great to have some sort of alert to tell you when Google Analytics finds one.
You can do this simply by creating a Custom Alert… here’s how!
- Click on Customisation > Custom Alerts.
- Click “Manage customised alerts”.
- Click the “+ New Alert” button on the following page.
- Add the following details into the Custom Alerts template and click Save Alert:
N.B. You can set the Period to Day, Week or Month and don’t forget to add the page title for your own “page not found” error page.
That’s it! Now you not only have a custom report to show you internal broken links in Google Analytics… but also an alert to let you know when Google Analytics finds any!
- You can see broken links in Google Analytics… but only if someone clicks one. If you want to see all your broken links you will need to use a tool that can spider your blog and check for them.
- Google Analytics includes an alert function. You can use it to set up a daily, weekly or monthly alert to let you know if someone clicks a broken link. You’d then need to run your broken links Custom Report to find where they are.
That’s all for now!
Have you used this technique to find broken links in Google Analytics? Let me know in a comment below.