跳至主要内容

Advertising

Pause the ads still selling a sold-out product

Stock hits zero at nine in the evening. The ad sets carrying that product keep spending until somebody opens the account the next morning. The fix is not clever, but it does need two halves: an event for speed, and a timer for the events that never arrive. Which ad sets to pause is a question about your own naming, and that has to be answered before any of this works.

Triggers
Two
Runs
Every 15 minutes
Stack
5 tools
Durable execution
Not required

The flow

The top track reacts to the stockout and records what it touches. The bottom track re-checks on a timer, and is the only part that catches a webhook that never landed.

Platform

Stock hits zero

Shopify Admin API

Orchestration

Find the ad sets

n8n · Make

Data

Hold the SKU-to-ad-set map

Sheets · Airtable

Orchestration

Every 15 minutes

n8n 排程

Platform

Read stock and ad status

Shopify Admin API · Meta Marketing API

Orchestration

Live on a zero-stock SKU?

n8n IF

Platform

Set the ad set to paused

Meta Marketing API · Google Ads API

Orchestration

Leave it running

Step by step

  1. 01

    Stock hits zero

    Shopify Admin API

    An inventory webhook fires. Treat it as a prompt to go and look, not as proof of the level — the number you act on should be one you read back.

  2. 02

    Find the ad sets

    n8n · Make

    Turn one SKU into the list of ad sets and ad groups still carrying it. This is the step that fails silently if your ad names do not contain the SKU, which is why the mapping is written down rather than inferred.

  3. 03

    Hold the SKU-to-ad-set map

    Sheets · Airtable

    One row per SKU with the ad sets it appears in, maintained by a person. A mapping guessed from ad names at runtime breaks the first time somebody renames a campaign.

  4. 04

    Every 15 minutes

    n8n 排程

    Runs whether or not a webhook arrived. This is the half that catches a delivery that failed at nine in the evening — the whole cost of missing it is a night of spend.

  5. 05

    Read stock and ad status

    Shopify Admin API · Meta Marketing API

    Pull the live stock level for the mapped SKUs and the current status of each ad set. Reading both is what makes the next step a decision rather than a guess.

  6. 06

    Live on a zero-stock SKU?

    n8n IF

    Both conditions must hold. An ad set already paused needs nothing done to it, and pausing it again is an operation you paid for.

  7. 07

    Set the ad set to paused

    Meta Marketing API · Google Ads API

    Pause at the ad set or ad group level, never at campaign level — a campaign usually carries products that are still in stock. Post the list of what was paused to the same channel that will have to switch it back on.

What the platform will not allow

Two of these set the shape of the flow. The third is the reason the paused state is harder to confirm than it looks.

  • Shopify states that "webhook delivery isn't always guaranteed" and that it "doesn't guarantee ordering within a topic, or across different topics for the same resource". Its own remedy is the bottom track here: "For redundancy, use reconciliation jobs to periodically fetch data from Shopify so that your app stays consistent with Shopify's data."

    Shopify — About webhooks (best practices)
  • Shopify allows "a one-second connection timeout and a five-second timeout for the entire request", then "retries 8 times over the next 4 hours". After 8 consecutive failures a subscription configured through the Admin API is deleted automatically — so an endpoint down over a long weekend can come back with nothing subscribed at all.

    Shopify — Deliver webhooks through HTTPS
  • On Meta, status is "the status set at the ad set level", while effective_status "could be effective either because of its own status, or the status of its parent campaign" and returns values like CAMPAIGN_PAUSED. Checking the field you wrote tells you what you asked for; checking effective_status tells you whether the ad is actually off.

    Meta Marketing API — Ad Set reference
  • Every pause is metered. Google Ads allows 15,000 operations per day on Basic access, counting "the total sum of get requests and mutate operations", and "requests that are rejected with a GoogleAdsFailure still count against the user's daily operation quota" — so a sweep that re-pauses what is already paused burns budget it did not need to.

    Google Ads API — API limits and quotas

When this is not worth building

Three cases where the upkeep costs more than a night of wasted spend.

  • You accept backorders. Then a zero is not a stop signal, it is a delivery date, and pausing the ad turns a sale you could have had into nothing at all.

  • Ad sets are not organised by product. If one ad set carries forty SKUs, pausing it because one sold out costs more than the wasted clicks, and no automation can make that trade for you.

  • Nobody owns switching them back on. An automation that only pauses will quietly shrink the account week by week, and the day stock returns the ads stay dark because nobody was told.

Related reading

联络我们

这些流程,你真正应该做哪一条?

我们每星期都在为香港的运营团队跑这些流程。告诉我们哪个环节正在耗你的时间,我们会告诉你自动化划不划得来。

开始对谈