Technical SEO: Checking 404 Errors and Status Codes Using
Technical SEO: Checking 404 Errors or Status Codes with Google Functions Minutes reading time remaining By Antonio Blago October 13, 2024
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/
E-commerce SEO Case Study for PURELEI
E-commerce SEO Case Study: PURELEI.com +100% visibility in 8 months
Case study, SEO, strategies
E-commerce SEO Case Study for PURELEI
E-commerce SEO Case Study: PURELEI.com +100% visibility in 8 months [...]
Case study, SEO
Case Study: How we generated over €1.2 million in revenue with targeted blog content
Brief overview
A fast-growing brand was able to generate over €1.2 million in revenue within 12 months through targeted content strategies and [...]
Automation, AI, SEO
Finally Accessible: Efficiently Filling ALT Texts with AI
5 (1)
Practical example in Shopify
In my job as an SEO freelancer [...]
Analysis, AI, SEO, SEO Tools
AI Prompt Keyword Mapper
0 (0)
How to automatically analyze prompts
Nowadays, prompts – that is, [...]
SEO, Shopify
Part 2: Automating Shopify Redirects: Connecting Sitemaps, Excel & Matrixify with Python
0 (0)
📖 Part of a series: Why missing redirects cost you traffic [...]
SEO, Shopify
Part 3: Planning Shopify Redirects Internationally: Correctly Combining Subdomains, Slugs & Sitemap Fallbacks
0 (0)
📖 Part of a series: Why missing redirects cost you traffic [...]
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Use my SEO roadmap to get on page 1 of Google!
Sign up for my newsletter and get access to free guides, checklists, and tools.