# Fetch Google Shopping Feeds

> Request fresh fetches for your file-based Merchant Center data sources and log every outcome in a Google Sheet.

This free script asks Merchant Center to re-fetch your file-based data sources on demand, instead of
waiting for their next scheduled fetch, and writes what happened to a Google Sheet. It is the answer
to "I updated the feed file, so why is Merchant Center still showing yesterday's prices?".

## What it does on each run

The script lists every data source in your Merchant Center account, page by page so large accounts
are covered in full, and looks at each one in turn. A data source gets a fetch request only when it
takes a file as input and has fetch settings enabled. Everything else is recorded and skipped rather
than silently ignored, so the sheet shows the whole account, not just the parts that acted.

## What lands in the sheet

Results go to a tab named **Feeds**, which is cleared and rewritten on every run, so the sheet
always reflects the latest run rather than growing indefinitely. Each row holds:

- Date and time of the run.
- Merchant Center ID.
- Feed name and feed ID.
- Status.
- Fetch URL.
- Content type, reported as Primary product, Supplemental product, Local inventory or Promotion.

## Reading the status column

| Status                    | What it means                                                                 |
| ------------------------- | ----------------------------------------------------------------------------- |
| Fetch requested           | Merchant Center accepted the request and will pull the file                   |
| Skipped: not a file input | The data source is not file-based, for example an API or a content feed       |
| Skipped: fetch disabled   | The data source takes a file, but scheduled fetching is switched off          |
| Fetch error               | Merchant Center rejected the request for this data source; the reason follows |
| List error                | The account itself could not be read, so no data source was reached           |

A fetch error affects only its own row. The script keeps going through the remaining data sources
rather than stopping at the first failure.

## Setting it up

1. Enable the **Merchant API Accounts** and **Merchant API DataSources** sub-APIs from Advanced
   APIs.
2. Set `merchantId` to your Merchant Center account ID.
3. Set `merchantApiDeveloperEmail` to the email address of the Google account that authorizes the
   script.
4. Optionally set `spreadsheetURL`. Leave it empty and the script creates a report spreadsheet for
   you and logs the URL.
5. Run the script.

The authorizing account needs Admin access to your Merchant Center account.

## The first run registers your access

Merchant API requires the script's Google Cloud project to be registered with your Merchant Center
account once. The script checks whether that registration already exists before trying to create
one, so it registers exactly once and keeps your Merchant Center API Diagnostics report free of
failed requests.

When the registration is missing, the first run creates it, logs that activation takes about five
minutes and stops. Wait, then run the script again. Later runs go straight to work.

## When Admin access sits on a manager account

If the authorizing Google account has Admin access to a Merchant Center advanced (manager) account
rather than to the shop account itself, registration against the shop account fails and Google names
the account it will accept instead.

Put that account ID in `merchantApiRegistrationAccountId` and run again. One registration covers
every Merchant Center account that user can reach, and data sources are still read from
`merchantId`.

## When to use this script

Reach for it when your feed file updates more often than Merchant Center fetches it, typically
because prices or stock move during the day and the scheduled fetch is once every 24 hours.
Scheduling this script a few times a day closes that gap without changing anything in your feed
setup.

It is also useful after a bulk change. Push a corrected file, run the script and check the sheet to
confirm every data source was picked up rather than assuming it was.

## Practical tips

- Point `spreadsheetURL` at a fixed sheet once you are past testing, so you always look in the same
  place.
- Check the skipped rows the first time you run it. A data source you expected to refresh but that
  reads "fetch disabled" is a Merchant Center setting to change, not a script problem.
- Do not schedule it more often than your file actually changes. Re-fetching an unchanged file costs
  you the request and gains nothing.

See also [Shopping Product Alert](/docs/google-ads-scripts/shopping-product-alert), which uses the
same Merchant API setup and tells you when the products in these feeds stop serving.
