How to track competitor prices in Google Sheets
You can watch a handful of competitors’ prices in a free Google Sheet, with no code for simple pages and a short script for the rest. This guide shows both, and where they stop working.
Option 1: IMPORTXML, no code
For a product page that shows its price in the page’s HTML, Google Sheets can read it with one formula:
=IMPORTXML(A2, "//meta[@property='product:price:amount']/@content")
- Put each product URL in column A.
- Find where the price sits. Many shops publish it in a meta tag (as above) or in structured data. In Chrome, right-click the price, choose Inspect, and note the tag and its attributes.
- Write an XPath for it, such as
//span[@class='price'], and fill the formula down.
Where it stops: Sheets refreshes import functions on its own schedule, which you don’t control, and it can’t read prices that a page loads with JavaScript after it opens. Many larger shops also refuse automated requests. It also keeps no history: when the price changes, the old one is gone.
Option 2: a short Apps Script with a history
Apps Script, built into Google Sheets, can fetch each page once a day and add a dated row, so you build a price history.
- In the sheet, open Extensions → Apps Script.
- Paste the script below, then save.
- Under Triggers, add a time-driven trigger that runs
logPricesonce a day.
function logPrices() {
const ss = SpreadsheetApp.getActive();
const urls = ss.getSheetByName('Products').getRange('A2:A').getValues().flat().filter(String);
const log = ss.getSheetByName('History');
urls.forEach(function (url) {
const html = UrlFetchApp.fetch(url, { muteHttpExceptions: true }).getContentText();
const m = html.match(/"price"\s*:\s*"?([0-9.]+)/);
log.appendRow([new Date(), url, m ? Number(m[1]) : 'not found']);
Utilities.sleep(2000); // be polite: one page every two seconds
});
}
It looks for the "price" field in the product’s structured data, which most shop platforms publish for search engines. Shopify stores also publish each product as JSON at the product URL plus .json, which is easier to read reliably.
Where it stops: pages that need JavaScript, shops that block scripts, prices that differ by size or colour, and your own time when a site changes its layout.
Play fair
- Read public pages only, and check each site’s robots.txt and terms.
- Fetch slowly: once a day is plenty for prices.
- Prices are facts, but product photos and descriptions are someone’s work. Keep to the numbers.
When to hand it off
Once you track more than a few dozen products, need stock levels or alerts, or a site starts blocking you, a hosted monitor saves time. We set up price and stock monitors from $150, with a free sample of 20 rows from your competitors first.