How to Check URL Indexing in Google Using Google Sheets

To verify whether a URL is indexed by Google, you can use Google Apps Script integrated with Google Sheets. The script will utilize UrlFetchApp to send requests and check the status of URLs via the site: search query.

Steps:

  1. Open Google Sheets.
  2. Click on “Extensions” -> “Apps Script”.
  3. Remove all text and insert the following code:
function checkIndexStatus(url) {
  try {
    var searchQuery = 'site:' + url;
    var searchURL = 'https://www.google.com/search?q=' + encodeURIComponent(searchQuery);
    var response = UrlFetchApp.fetch(searchURL, {muteHttpExceptions: true}).getContentText();

    if (response.includes('did not match any documents')) {
      return 'Not Indexed';
    } else {
      return 'Indexed';
    }
  } catch (error) {
    return 'Error: ' + error.message;
  }
}

function checkURLsInSheet() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var lastRow = sheet.getLastRow();
  
  for (var i = 2; i <= lastRow; i++) {  // Assuming the first row contains headers
    var url = sheet.getRange(i, 1).getValue(); // URLs are in the first column
    var status = checkIndexStatus(url);
    sheet.getRange(i, 2).setValue(status);  // Status will be in the second column
  }
}
  1. Save the script, for example, as CheckIndexStatus.
  2. Return to Google Sheets.
  3. Enter a list of URLs in the first column (starting from the second row).
  4. Run the checkURLsInSheet function via the Apps Script editor or the “Run” menu in the editor.

How the Script Works

  • checkIndexStatus(url): This function sends a search query to Google using the site: command to check if the URL is indexed.
  • checkURLsInSheet(): This function loops through each URL in your Google Sheet and writes the result of the check (indexed or not) in the second column.

This method relies on parsing the HTML of Google’s search results page. Its effectiveness may be limited, and Google could restrict such requests if they are sent too frequently. Use this approach sparingly to avoid potential issues.

5/5 - (3 votes)