A Google Sheet Script to Find LinkedIn Company Pages

October 23, 2025

If you're working with a list of company websites in a Google Sheet and need to find their official LinkedIn pages, this script can save you a lot of manual work. I've been using it myself to track down LinkedIn company posts, and it's quite handy.

What the Script Does

This script goes through your list of company websites. For each one, it fetches the website's HTML and looks for a LinkedIn company page URL (like linkedin.com/company/company-name). If it finds one, it puts that LinkedIn URL into another column in your sheet. If not, it just marks it "Not found." This works most of the time because around 90% of B2B companies link to their LinkedIn page from their homepage.

How to Set Up Your Sheet

For the script to work correctly, here's how your sheet should be organized:

  • Column A: This is where your company website URLs go (e.g., example.com).
  • Column B: This is where the script will write the LinkedIn URLs it finds. Make sure this column is empty for the rows you want to process. The script is designed to skip any row that already has a value here, so you can run it multiple times without re-processing old data.

The Script

You can add this code to your Google Sheet by going to Extensions > Apps Script.

function findLinkedInURLs() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const startRow = 2; // IMPORTANT: Update this to the actual row where your data starts
  const numRows = 1000; // How many rows you want to process in one go
  const range = sheet.getRange(startRow, 1, numRows, 1); // Reads from Column A
  const urls = range.getValues();

  urls.forEach((row, index) => {
    const website = row[0];
    const currentRow = startRow + index;

    // Skip if Column B already has a value or if the website cell is empty
    const existingValue = sheet.getRange(currentRow, 2).getValue();
    if (existingValue || !website) return;

    try {
      // Fetch the website's HTML
      const html = UrlFetchApp.fetch(website, {
        muteHttpExceptions: true,
        followRedirects: true
      }).getContentText();

      // Look for the LinkedIn company URL using a regular expression
      const linkedInMatch = html.match(/https?:\/\/(www.)?linkedin.com\/company\/[a-zA-Z0-9-]+/i);

      if (linkedInMatch) {
        sheet.getRange(currentRow, 2).setValue(linkedInMatch[0]); // Writes to Column B
      } else {
        sheet.getRange(currentRow, 2).setValue("Not found");
      }
    } catch (e) {
      sheet.getRange(currentRow, 2).setValue("Error");
    }

    // Pause for 2 seconds to avoid overwhelming servers
    Utilities.sleep(2000);

    // Log progress in the Apps Script console every 50 rows
    if ((index + 1) % 50 === 0) {
      Logger.log(`Processed ${index + 1} rows`);
    }
  });

  Logger.log("Processing complete.");
}

Important Notes Before Running

  • `startRow`: You'll need to update the const startRow = 2; line to match the row where your data actually begins in the sheet.
  • Execution Limits: Google Apps Scripts have a time limit (usually 6 minutes per run). Because this script pauses for 2 seconds between requests, it can process about 180 rows in one go. If you have a longer list, just run the script again; it's designed to pick up where it left off.