Technical SEO: Checking 404 Errors and Status Codes Using

Antonio Blago
Antonio Blago
1 readers 5.0/5 (1)

Advanced SEO, Google Search Console

What is technical SEO?

Correct indexing of your web pages is a crucial lever for being visible in Google's search results. As long as your pages are not properly indexed, they have no chance of appearing in the search results. This can be especially frustrating for online shops, as potential customers cannot find your products if these pages do not meet the necessary criteria.

This is where the status code comes into play: Every time a web page is accessed, it returns an HTTP status code that indicates whether the page loaded correctly or if there were problems (e.g., a 404 error for pages not found or a 500 error for server issues). Checking these codes is essential to identify and fix indexing errors.

While the Google Search Console provides helpful insights, it is beneficial to regularly check the status code of your pages yourself. That's why I developed a script for Google Sheets that allows you to easily monitor the status code of your pages. This way, you can quickly determine if there are technical issues preventing proper indexing and take targeted action.

1. Exporting Google Sheets Data from Google Search Console

Log in to Google Search Console:

Visit the Google Search Console and log in with your Google account.

Select your website property:

Choose the website property you want to analyze from the property menu in the upper left corner.

Access the pages report:

Click on 'Pages' in the left sidebar to access the report on the index status of your pages.

Filter for errors:

Select 'Not found (404)'. This will show pages that Google tried to crawl but returned an HTTP error status.

Export the data:

Click the 'Export' button, which is usually located at the top right of the report.

Select the Google Sheets format and open it.

2. Preparing the Exported Data for Analysis

Organize URLs:

Make sure the URLs are in a single 'URL' column; if they are not already, delete the date column and add a new "Status" column. This is necessary for the script to process them correctly.

3. Setting Up the Google App Script for URL Checking

Access Google Scripts:

Go to Extensions > Apps Script

Copy and paste this code into the empty window

function checkPageStatus(url){
var options = {
'muteHttpExceptions': true,
'followRedirects': false
};
var url_trimmed = url.trim();
var response = UrlFetchApp.fetch(url_trimmed, options);
var statusCode = response.getResponseCode();

// Check if the status code is 200 or 404 and return a message or boolean value accordingly
if (statusCode === 200) {
return "Okay! (Status code: 200)";
} else if (statusCode === 404) {
return "Page not found. (Status code: 404)";
} else {
return "Page returned a different status code: " + statusCode;
}
}

and save it using the small disk icon.

Analyzing the Results

Run our custom function from the Google Sheet:

Once the script is ready, check the specified column in your sheet for the HTTP status codes.

Identify 404 errors:

Filter or search the column with the status codes for '404'. These represent the URLs that lead to 'Not found' pages.

Take action:

Decide on an appropriate action for each 404 error, such as setting up a redirect, restoring the missing content, or updating the link to point to a current page.

By following these detailed steps, you should be able to efficiently identify and fix 404 errors on your website, thereby improving the user experience and possibly the SEO performance of your site.

Contact me for further support 🙂

The original source for this script is https://nofluffdigital.com/blog/seo/google-app-scripts-url-checker/

 
Cookie-Settings