# Shopping Product Alert

> Get an email when advertised Shopping products are disapproved, limited or out of stock in Merchant Center.

> **Prefer to run this in the app?** The _Shopping product alert_
> [automation](/docs/automations/automations) runs the same check from Flowboost on a schedule and
> emails you what it finds. It is a separate product, so settings are not shared between the two.

This free script protects your Shopping campaigns by checking the products you actually advertise
against their Shopping Ads status in Merchant Center, then emailing you when something needs
attention. A disapproved product stops serving quietly, so the point of the script is to tell you
before you notice the missing revenue.

## How it decides what to check

The script starts from Google Ads, not from your feed. It reads the products that had impressions
in your selected period, which defaults to the last 30 days, and only those products are looked up
in Merchant Center. A product sitting in your feed that you never advertise raises no alert, which
keeps the email about campaigns you are actually running.

Merchant Center statuses are read for the Shopping Ads reporting context only, so an issue that
affects a different surface, such as free listings, does not trigger an alert here.

## What the email contains

One entry per affected product, with:

- The product ID and title.
- A direct link to that product in Merchant Center, so you can open it and start fixing.
- The issue type Merchant Center reported.
- The countries the product is disapproved in, when Google reports any.
- The severity, shown as Disapproved, Limited or Out of stock.

If nothing matches, no email goes out. The run logs that it found nothing rather than sending an
all-clear you would learn to ignore.

## Choosing which statuses alert you

By default the script alerts only on **disapproved** products. That default exists because
out-of-stock items are normal in most shops and including them tends to produce a long daily email
nobody reads.

Widen it with the `alertStatuses` setting, which accepts one or more of:

- `DISAPPROVED`, products that are blocked from serving.
- `LIMITED` (also accepted as `DEMOTED`), products that serve with restrictions.
- `OUT_OF_STOCK`, products Merchant Center reports as unavailable.

## Setting it up

1. Enable the **Merchant API Accounts** and **Merchant API Reports** sub-APIs from Advanced APIs.
2. Set `merchantId` to your Merchant Center account ID.
3. Set `email` to the addresses that should receive the alert.
4. Set `merchantApiDeveloperEmail` to the email address of the Google account that authorizes the
   script.
5. Run the script.

The authorizing account needs Admin access to your Merchant Center account, or to the advanced
(manager) account above it.

## 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 exists before it tries to create one, so
it registers exactly once and leaves your Merchant Center API Diagnostics report clean rather than
filling it with 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. Every later run skips this step entirely.

## 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. Google names
the account it will accept at the end of its error message.

Put that account ID in `merchantApiRegistrationAccountId` and run again. One registration covers
every Merchant Center account that user can reach, and products are still read from `merchantId`,
so this changes where the script registers and nothing about what it reports on.

## What the log tells you

The script is deliberate about failure messages: each one names the account involved and the next
step to take. A missing Merchant Center ID is caught before any API call is made, a missing
authorizing email is reported before registration is attempted and a read failure explains which
account the project is registered with, so you can tell a permissions problem from a wrong ID.

## Practical tips

- Schedule it daily. Disapprovals are worth catching within a day, not within a week.
- Start with the default `DISAPPROVED` only, then add `LIMITED` once you are on top of the
  disapprovals.
- Raise `periodDays` if you have a long tail of products that sell infrequently, so a product that
  only got impressions three weeks ago is still checked.
- Only add `OUT_OF_STOCK` if your stock levels are stable enough for it to be signal rather than
  noise.

See also [Fetch Google Shopping Feeds](/docs/google-ads-scripts/fetch-google-shopping-feeds), which
uses the same Merchant API setup and keeps the feed behind these products up to date.
