add the apps script

How to Automatically Pull Meta Titles and Descriptions into Google Sheets

On this page

    When managing hundreds of URLs, manually checking page titles and meta descriptions can waste valuable time. With Google Sheets and a simple Apps Script, you can automate the process and pull this metadata directly into your spreadsheet.

    Step 1: Prepare Your Spreadsheet

    1. Open a new Google Sheet.
    2. In column A, list the URLs you want to analyse. Start from cell A2 (keep A1 as your header, e.g., “URL”).

    prepare your spreadsheet

    Step 2: Add the Apps Script

    1. Go to the menu: Extensions → Apps Script.
    2. Delete any default code in Code.gs.
    3. Paste the following script:
      /**
      * GET_META(url) -> returns [title, description] (spills into two adjacent cells)
      * GET_META_RANGE(A2:A50) -> returns rows of [title, description] for each URL
      */function GET_META(url) {
      if (!url) return [[”,”]];
      try {
      var res = UrlFetchApp.fetch(url.toString(), {muteHttpExceptions: true});
      var html = res.getContentText();
      var parsed = _parseMeta(html);
      return [[parsed.title || ”, parsed.description || ”]];
      } catch (e) {
      return [[‘ERROR: ‘ + e.message, ”]];
      }
      }function GET_META_RANGE(inputRange) {
      if (!inputRange) return [];
      var urls = [];
      for (var i = 0; i < inputRange.length; i++) urls.push(inputRange[i][0]);
      var requests = [], indexMap = [];
      for (i = 0; i < urls.length; i++) {
      var u = urls[i];
      if (!u) { indexMap.push(-1); continue; }
      indexMap.push(requests.length);
      requests.push({ url: u.toString(), muteHttpExceptions: true });
      }
      var responses = requests.length ? UrlFetchApp.fetchAll(requests) : [];
      var out = [];
      for (i = 0; i < urls.length; i++) {
      if (indexMap[i] === -1) { out.push([”,”]); continue; }
      var res = responses[indexMap[i]];
      var html = res.getContentText();
      var parsed = _parseMeta(html);
      out.push([parsed.title || ”, parsed.description || ”]);
      }
      return out;
      }

      function _parseMeta(html) {
      var headMatch = html.match(/<head[\s\S]*?<\/head>/i);
      var head = headMatch ? headMatch[0] : html;
      var title = (head.match(/<title[^>]*>([\s\S]*?)<\/title>/i) || [null, ”])[1] || ”;
      if (title) title = title.replace(/\s+/g,’ ‘).trim();
      var desc = ”;
      var m = head.match(/<meta[^>]*name=[“‘]description[“‘][^>]*content=[“‘]([\s\S]*?)[“‘][^>]*>/i)
      || head.match(/<meta[^>]*property=[“‘]og:description[“‘][^>]*content=[“‘]([\s\S]*?)[“‘][^>]*>/i)
      || head.match(/<meta[^>]*name=[“‘]og:description[“‘][^>]*content=[“‘]([\s\S]*?)[“‘][^>]*>/i);
      if (m) desc = m[1].replace(/\s+/g,’ ‘).trim();
      if (!title) {
      var mt = head.match(/<meta[^>]*property=[“‘]og:title[“‘][^>]*content=[“‘]([\s\S]*?)[“‘][^>]*>/i)
      || head.match(/<meta[^>]*name=[“‘]title[“‘][^>]*content=[“‘]([\s\S]*?)[“‘][^>]*>/i);
      if (mt) title = mt[1].replace(/\s+/g,’ ‘).trim();
      }
      return { title: title, description: desc };
      }

      function AUTHORIZE() {
      UrlFetchApp.fetch(‘https://www.google.com’);
      }

    4. Save the project (name it anything you like). In the image below, I have highlighted the save button too. It looks like a floppy icon. Unless you click on Save, you will not see the options for the next step.add the apps script

     

    Step 3: Authorise the Script

    1. In the Apps Script editor, select AUTHORIZE from the dropdown.
    2. Click Run.
    3. Approve the Google permissions when prompted.

    authorise the script

    Once the script is authorized, it will look like this:

    authorization completed

    Now go back to the sheet once the authorization is done.

    Step 4: Use the Formulas in Google Sheets

    • For a range of URLs: In cell B2, enter:
      =GET_META_RANGE(A2:A20)

      Hit Enter.

      This will fill columns B (Title) and C (Description) for all URLs in A2:A20.

      Please note: I have used the range A2:A20 because my last URL is row 20. You need to update it as per your last row.

    add formula to cell

    • For a single URL: In cell B2, enter:
      =GET_META(A2)

      The title and description will appear in B2 and C2.

    Here is the Google Sheet link with the final output: https://docs.google.com/spreadsheets/d/1ZUGNI1y9JEt5gmdHqWAfpKAsClvxDwswnKBCZtFg7mE/edit?usp=sharing

    Bonus Point: Work in Batches

    Fetching metadata for too many URLs at once may exceed Google’s quotas. Run in blocks of 30–50 URLs per formula.

    Final Notes

    • Titles and descriptions are pulled from the <title> tag and <meta name="description">. If missing, the script tries og:title and og:description.
    • If you see #ERROR!, re‑run AUTHORIZE.
    • Some websites may block Google fetch requests, returning blank cells.

    This setup lets you quickly audit and export metadata for hundreds of URLs without leaving your spreadsheet.

    Post Category:

    Share this article:

    Ankit Chauhan is an SEO Consultant and Researcher. Having more than 5 years of extensive experience in SEO, Ankit loves to share his SEO expertise with the community through his blog. Ankit Chauhan is a big-time SEO nerd with an obsession for search engines and how they work. Ankit loves to read Google patents about search engines and conduct SEO experiments in his free time.

    Related Posts

    add the apps script

    How to Automatically Pull Meta Titles and Descriptions into Google Sheets

    content after doing good work

    How a Client Meeting Changed The Way I Look At My Work

    site revival

    How Updating My About Us Page Brought My Website Back to Life

    Let’s Make Something Rank

    Whether you’re a brand in India, an agency overseas, or a founder who’s tired of being buried under your competitors - I’m ready when you are.

    Let’s build something search engines (and your users) can’t ignore.

    Drop a message. I’ll respond like a human, not a sales funnel.