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
- Open a new Google Sheet.
- In column A, list the URLs you want to analyse. Start from cell A2 (keep A1 as your header, e.g., “URL”).
Step 2: Add the Apps Script
- Go to the menu: Extensions → Apps Script.
- Delete any default code in
Code.gs
. - 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’);
} - 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.
Step 3: Authorise the Script
- In the Apps Script editor, select AUTHORIZE from the dropdown.
- Click Run.
- Approve the Google permissions when prompted.
Once the script is authorized, it will look like this:
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.
- 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 triesog:title
andog: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.