Skip to content

Ecommerce checkout alerts: find out when your checkout stops converting

From the work/ 17 min read

A Node script that runs every 10 minutes, compares orders with last week, counts failed payments and abandoned checkouts, probes the checkout and posts to Slack.

  • Shopify
  • Analytics
  • Node.js
  • Admin API
In this article (9)
  1. Why you find out late
  2. Alert 1: orders per hour vs the same hour last week
  3. Alert 2: payment errors
  4. Alert 3: checkout down
  5. Send the alert by email or Slack
  6. Test the alerts
  7. Common mistakes
  8. Frequently asked questions
  9. Checklist

To learn in time that your checkout stopped selling on a big sale day, schedule a script that runs every 10 minutes and checks three alerts: orders in the last hour against the same hour last week, payment errors, and a synthetic checkout probe. When one fires, it posts to Slack and emails you.

We wrote it for Mexico's Buen Fin, which runs from Friday, November 13 to Tuesday, November 17, 2026 under the 2026 Buen Fin operating rules from Mexico's Ministry of Economy, and it works the same for Black Friday on November 27. Below is the full Node script, with no dependencies, its queries validated against version 2026-10 of Shopify's APIs and tested against stubbed responses. It pairs with the checkout smoke test and change freeze: that one checks before the sale that people can buy; this one watches during the sale that they still do.

Why you find out late

Shopify does not tell you when sales drop. Analytics shows the dip to whoever opens it, and on a sale day the team is answering messages and packing orders. Most stores find out from a customer who writes "it won't let me pay", or the next morning. The cause is usually a small change: an app update, a theme tweak, a discount rule, a payment provider having a bad day.

You do not need to guess which one. Watch three signals you can read through Shopify's APIs; each one catches a different failure:

  • Orders per hour. Catches anything that ends in fewer sales, but it needs volume and arrives late, because it measures a full hour.
  • Payment errors. Failed transactions and the share of abandoned checkouts point at the payment step.
  • Checkout down. A synthetic probe that does not depend on volume and still alerts in the middle of the night.

A dashboard needs someone watching it. This script runs on its own, compares against your store's own history and messages you when something is off. It installs no app and does not touch your theme.

Alert 1: orders per hour vs the same hour last week

Sales follow a daily rhythm, so the fair comparison is the same hour on the same weekday last week: Friday at 1 p.m. against last Friday at 1 p.m. On a sale day you should sell more than in an ordinary week, so falling below half of it is a clear sign that something broke.

Admin API access

The script needs a token with the read_orders scope. Per Shopify's changelog, since January 1, 2026 you can no longer create custom apps in the store admin: you build them in the Dev Dashboard. For an app like that, the script requests a token through the client credentials grant, which returns a 24-hour token and only works when the app and the store belong to the same organization.

const postJson = (url, payload, headers = {}) =>
  fetch(url, { method: "POST", headers: { "Content-Type": "application/json", ...headers }, body: JSON.stringify(payload) });

async function getToken() {
  if (SHOPIFY_ADMIN_TOKEN) return SHOPIFY_ADMIN_TOKEN;
  const res = await fetch(`https://${SHOP}/admin/oauth/access_token`, {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    body: new URLSearchParams({
      grant_type: "client_credentials",
      client_id: SHOPIFY_CLIENT_ID,
      client_secret: SHOPIFY_CLIENT_SECRET,
    }),
  });
  if (!res.ok) throw new Error(`token request: HTTP ${res.status}`);
  return (await res.json()).access_token;
}

async function admin(token, query, variables) {
  const url = `https://${SHOP}/admin/api/${API_VERSION}/graphql.json`;
  const res = await postJson(url, { query, variables }, { "X-Shopify-Access-Token": token });
  const body = await res.json().catch(() => ({}));
  if (!res.ok || body.errors) throw new Error(`HTTP ${res.status} ${JSON.stringify(body.errors ?? "")}`);
  return body.data;
}
  1. postJson sends a POST with a JSON body. The Admin API calls, the checkout probe and the Slack alert all use it.
  2. If you have the token of a custom app created before 2026, put it in SHOPIFY_ADMIN_TOKEN and getToken uses it as is.
  3. Otherwise it requests one from /admin/oauth/access_token with grant_type=client_credentials, client_id and client_secret, form-encoded. It lasts 86399 seconds, and the script asks for a fresh one on every run.
  4. admin uses version 2026-10, the latest stable one per Shopify's versioning page: released October 1, 2026 and available until October 16, 2027.
  5. It throws when the HTTP call fails or the response carries errors: the Admin API reference explains that GraphQL can answer 200 OK in cases that would be errors in REST, such as THROTTLED.

The query

One request returns the four numbers alerts 1 and 2 need:

const COUNTS = `query Counts($now: String!, $lastWeek: String!) {
  ordersNow: ordersCount(query: $now) { count }
  ordersLastWeek: ordersCount(query: $lastWeek) { count }
  abandonedNow: abandonedCheckoutsCount(query: $now) { count }
  abandonedLastWeek: abandonedCheckoutsCount(query: $lastWeek) { count }
}`;

const between = (end) =>
  `created_at:>='${new Date(end - HOUR).toISOString()}' created_at:<'${new Date(end).toISOString()}'`;
  1. Counts asks for four aliased counts: orders and abandoned checkouts, in the current window and in the one a week earlier.
  2. ordersCount and abandonedCheckoutsCount return a Count and accept the created_at filter. They count up to 10,000 by default.
  3. between builds the filter in Shopify's search syntax: dates in quotes, as the docs require, and a space between terms, which means AND.

The window is one hour long and ends 15 minutes before the run: at 1:00 p.m. it reads 11:45 to 12:45, and the same slice last week. Alert 2 needs that delay, and both alerts share the window so their numbers line up.

The rule

const DROP_RATIO = 0.5; // alert 1: fewer than half of last week's orders...
const MIN_BASELINE = 10; // ...when last week had at least 10 in that hour

// Alert 1: orders in the hour vs the same hour last week.
function ordersAlert({ ordersNow, ordersLastWeek }) {
  if (ordersLastWeek.count >= MIN_BASELINE && ordersNow.count < ordersLastWeek.count * DROP_RATIO) {
    return `Orders: ${ordersNow.count} in the hour vs ${ordersLastWeek.count} same hour last week`;
  }
}
  1. It alerts when there are fewer than half of last week's orders (DROP_RATIO), and only if that hour had at least 10 (MIN_BASELINE).
  2. The floor keeps the night quiet: going from 2 orders to 0 means nothing, and an alert that fires for nothing ends up muted.
  3. It returns the alert text, or undefined when all is well.

Both numbers are an illustrative example: find the weakest normal hour of the past few weeks in your reports and tune them. If you sell only a few orders an hour, use 3 * HOUR in between for a three-hour window.

orders per hour: today vs the same hour last weektoday (sale day)last weekthreshold: 50% of last week0204010:0011:0012:0013:0014:0015:0016:0017:00alert: 6 orders < 11a drop against last week fires the alertillustrative example: made-up data, threshold = 50% of the same hour

Scroll the figure sideways to see all of it

Alert 2: payment errors

This is where precision matters. The Shopify Help Center says a payment that fails at checkout usually does not create an order: it is recorded as an abandoned checkout, with the attempt in its timeline, and a checkout only counts as abandoned after more than 10 minutes incomplete. The Admin API defines an abandoned checkout as one where the customer added contact information and did not buy, and that object has no payment fields.

What happenedVisible in the Admin API?Where
An order was createdYesordersCount, orders
A transaction on an order failed or erroredYes, with a standard error codeOrderTransaction.status set to FAILURE or ERROR, plus errorCode
The bank declined the card and no order was createdOnly as an abandoned checkout, without the reason, and only if the customer left contact detailsabandonedCheckoutsCount; the reason, in the checkout's timeline in the admin
The checkout does not loadNoOnly through a synthetic probe (alert 3)

So alert 2 watches two things: failed transactions on recent orders and the share of abandoned checkouts.

const MAX_FAILED = 3; // alert 2: failed or errored transactions in the hour
const ABANDON_JUMP = 0.2; // alert 2: abandoned share up 20 points vs last week

const RECENT_ORDERS = `query RecentOrders($q: String!) {
  orders(first: 50, query: $q, sortKey: CREATED_AT, reverse: true) {
    nodes { name transactions(first: 5) { status kind gateway errorCode } }
  }
}`;

// Alert 2: failed transactions on recent orders, and abandoned checkouts (where declines land).
async function paymentAlerts(token, q, c) {
  const alerts = [];
  // shortcut: reads the latest 50 orders of the hour; page with `after` if you sell more per hour.
  const { orders } = await admin(token, RECENT_ORDERS, { q });
  const failed = orders.nodes.flatMap((o) =>
    o.transactions
      .filter((t) => t.status === "FAILURE" || t.status === "ERROR")
      .map((t) => `${o.name} ${t.kind} ${t.gateway} ${t.errorCode ?? t.status}`),
  );
  if (failed.length >= MAX_FAILED) alerts.push(`Payments: ${failed.length} failed (${failed.slice(0, 3).join("; ")})`);
  const share = (abandoned, orders) => (abandoned + orders ? abandoned / (abandoned + orders) : 0);
  const now = share(c.abandonedNow.count, c.ordersNow.count);
  const before = share(c.abandonedLastWeek.count, c.ordersLastWeek.count);
  if (c.abandonedNow.count >= MIN_BASELINE && now - before > ABANDON_JUMP) {
    alerts.push(`Abandoned checkouts: ${Math.round(now * 100)}% vs ${Math.round(before * 100)}% last week`);
  }
  return alerts;
}
  1. RecentOrders uses the orders query to read the 50 most recent orders in the window, with up to 5 transactions each. It is a shortcut: if you sell more than 50 an hour, page with after.
  2. failed keeps the transactions in FAILURE or ERROR, two OrderTransaction statuses, with their standard errorCode: CARD_DECLINED, PAYMENT_PROVIDER_ERROR, CONFIG_ERROR and others. With 3 or more in the hour, it alerts.
  3. share is abandoned divided by abandoned plus orders: an approximation, computed the same way for both weeks. With at least 10 abandoned checkouts and a rise of more than 20 points, it alerts; in our test, 67% against 25%.

It compares shares, not counts, because a sale day brings more visitors and more abandoned checkouts even when everything works. If the share jumps, open the timeline of a few of those checkouts in the admin to read the bank's message. And that is why the window ends 15 minutes early: a checkout from 5 minutes ago does not count as abandoned yet.

Alert 3: checkout down

The first two alerts need shoppers; this one does not. It is a synthetic probe that creates a cart and opens its checkout through the Storefront API without a token: per the Storefront API documentation, tokenless access can read and write carts.

const PROBE = `mutation Probe($variantId: ID!) {
  cartCreate(input: { lines: [{ merchandiseId: $variantId, quantity: 1 }] }) {
    cart { checkoutUrl totalQuantity }
    userErrors { message }
  }
}`;

// Alert 3: a synthetic check. Creates a cart (never an order) and loads its checkout URL.
async function probeCheckout() {
  const variables = { variantId: PROBE_VARIANT_ID };
  const res = await postJson(`https://${SHOP}/api/${API_VERSION}/graphql.json`, { query: PROBE, variables });
  const body = await res.json().catch(() => ({}));
  const cart = body.data?.cartCreate?.cart;
  if (!res.ok || !cart?.totalQuantity) {
    return `cartCreate: HTTP ${res.status} ${JSON.stringify(body.errors ?? body.data?.cartCreate?.userErrors ?? "")}`;
  }
  const page = await fetch(cart.checkoutUrl);
  if (!page.ok) return `checkout page: HTTP ${page.status}`;
}

async function checkoutAlert(sleep) {
  const first = await probeCheckout().catch((err) => err.message);
  if (!first) return;
  await sleep(30_000); // one retry, so a single blip does not page anyone
  const second = await probeCheckout().catch((err) => err.message);
  if (second) return `Checkout probe failed twice: ${second}`;
}
  1. cartCreate adds one unit of PROBE_VARIANT_ID and returns checkoutUrl and totalQuantity. An empty cart counts as a failure: the variant sold out or no longer exists.
  2. It then loads checkoutUrl with fetch, which follows redirects, and fails if the final response is not 2xx.
  3. checkoutAlert retries after 30 seconds and only alerts if both attempts fail. Every error, network errors included, becomes text and never crashes the script.

It catches a Storefront API that is down or returning errors, a variant that no longer goes into a cart, and a checkout page that returns an HTTP error or does not answer. It misses:

  • Declined cards or a payment provider outage: the probe never pays. Alert 2 watches that.
  • A broken pay button or an extension that blocks the step: fetch does not run the page.
  • Theme failures before the cart, which the Playwright smoke test covers in a real browser.
  • Problems tied to a single country, discount code or address.
  • A 200 response that is not the checkout, such as a redirect to another page: it passes as healthy.

Use a variant that will not sell out during the sale. Each run creates a real cart, never an order.

Send the alert by email or Slack

The script uses two channels with no dependencies. Slack, through an incoming webhook: a POST with a JSON body carrying text, which Slack answers with 200 and ok. And email, through GitHub: when there are alerts, the script exits with code 1, the run fails and GitHub notifies you.

export async function runChecks({ now = Date.now(), sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) {
  const alerts = [];
  const end = now - 15 * MINUTE; // a checkout counts as abandoned after 10+ minutes
  try {
    const token = await getToken();
    const counts = await admin(token, COUNTS, { now: between(end), lastWeek: between(end - WEEK) });
    alerts.push(ordersAlert(counts), ...(await paymentAlerts(token, between(end), counts)));
  } catch (err) {
    alerts.push(`Monitor could not read the Admin API: ${err.message}`);
  }
  alerts.push(await checkoutAlert(sleep));
  return alerts.filter(Boolean);
}

export async function main() {
  const alerts = await runChecks();
  if (!alerts.length) return console.log("ok");
  const text = `Checkout alert for ${SHOP}\n- ${alerts.join("\n- ")}`;
  console.log(text);
  const res = SLACK_WEBHOOK_URL && (await postJson(SLACK_WEBHOOK_URL, { text }));
  if (res && !res.ok) console.error(`Slack: HTTP ${res.status} ${await res.text()}`);
  process.exitCode = 1; // a failed run also emails you through GitHub Actions
}

if (process.argv[1] === fileURLToPath(import.meta.url)) await main();
  1. runChecks runs alerts 1 and 2 inside a try: if the token or the Admin API fails, that failure is an alert itself, because a broken monitor should speak up instead of going quiet.
  2. The checkout probe runs outside the try, so it still runs when the Admin API fails.
  3. main prints ok when there are no alerts. Otherwise it prints one message with all of them, posts it to Slack when SLACK_WEBHOOK_URL is set (a Slack error only goes to the log) and sets process.exitCode = 1. The last line only runs main from the command line, not when the tests import the file.

Schedule it every 10 minutes with GitHub Actions

# .github/workflows/checkout-monitor.yml
name: Checkout monitor
on:
  schedule:
    - cron: "5,15,25,35,45,55 * * * *"
  workflow_dispatch:
jobs:
  monitor:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 22
      - run: node monitor.mjs
        env:
          SHOP: ${{ secrets.SHOP }}
          SHOPIFY_CLIENT_ID: ${{ secrets.SHOPIFY_CLIENT_ID }}
          SHOPIFY_CLIENT_SECRET: ${{ secrets.SHOPIFY_CLIENT_SECRET }}
          PROBE_VARIANT_ID: ${{ secrets.PROBE_VARIANT_ID }}
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  1. 5,15,25,35,45,55 * * * * runs six times an hour, in UTC, and skips minute 0: per GitHub's schedule documentation, scheduled workflows can be delayed under high load, which includes the start of every hour, and some queued jobs may be dropped. The minimum interval is 5 minutes.
  2. workflow_dispatch adds a button to run it by hand.
  3. The values live in repository secrets: Slack warns that the webhook URL is a secret.

For email, turn on Actions notifications: per GitHub's notifications documentation, a scheduled workflow notifies the user who created it, or whoever last changed its cron, and you can limit notifications to failed runs. The workflow only runs on the default branch, is disabled in public repositories after 60 days without activity and, in a private one, uses your plan's included Actions usage, so you can enable it only for the week of the sale.

the scheduled script: every 10 minutes, three checks, one alertGitHub Actionsschedule5,15,…,55 * * * *monitor.mjsnode monitor.mjs1-hour window1 · orders/hourAdmin · ordersCount2 · payment errorstransactions · abandoned3 · checkout downStorefront · cartCreateif there are alertsPOST to Slack · exit 1 → GitHub emailno alertsprints "ok" · green runa broken Admin API call alerts toothe checkout probe runs even if the Admin API fails; it retries once after 30 s

Scroll the figure sideways to see all of it

Test the alerts

We tested the script locally with Node's test runner and a stubbed fetch: no call went out to Shopify, Slack or an email service. One of the tests:

const NOW = Date.parse("2026-11-13T19:00:00Z"); // Buen Fin, Friday 13:00 in Mexico City
const noSleep = async () => {};

test("alert 1: orders drop below half of the same hour last week", async () => {
  stub({ counts: { ordersNow: 4, ordersLastWeek: 31, abandonedNow: 3, abandonedLastWeek: 9 } });
  const alerts = await runChecks({ now: NOW, sleep: noSleep });
  assert.deepEqual(alerts, ["Orders: 4 in the hour vs 31 same hour last week"]);
});
  1. NOW is Friday, November 13 at 1 p.m. in Mexico City (19:00 UTC); noSleep skips the wait before the retry.
  2. stub replaces globalThis.fetch and answers by URL; here, 4 orders against 31 last week.
  3. The test expects exactly that alert.

With node --test, all 12 tests passed: a normal hour, with the exact 17:45 to 18:45 UTC window; an orders drop; a low-volume hour that stays quiet; three failed payments; a jump in abandoned checkouts; a checkout that fails twice; a single failure that does not alert; an empty cart; a network error; a broken token, which alerts and still lets the checkout probe run; and one Slack message with exit code 1. Removing the retry from the code made 4 of them fail. From the command line, with a stubbed fetch, it printed ok with exit code 0 in a normal hour and the alert with exit code 1 on a drop.

the three alerts: what they read and when they firealertsignalthreshold (example)window1 · orders/hourordersCountcreated_at< 50% of last weekif it had ≥ 101 h, ending15 min ago2a · failed paymentstransactionsFAILURE or ERROR≥ 3 in the hourlatest 50orders2b · abandonedabandonedCheckoutsCount+20 points ofabandon share, if ≥ 101 h, ending15 min ago3 · checkout downcartCreate +checkoutUrlfails twicein a row30 s betweenattemptsexample thresholds: tune them to your own historyillustrative example; tested against stubbed responses, not a real store

Scroll the figure sideways to see all of it

We did not run it against a real store. Do that yourself before the sale: run the workflow by hand and check that it ends green. Then set PROBE_VARIANT_ID to an ID that does not exist and run it again: the alert should reach Slack, the run should turn red and the email should arrive. Put the secret back. That tests the whole path without touching an order.

Common mistakes

  • Alerting on any drop. Without a minimum number of orders, the night fills the channel with noise and someone mutes it.
  • Comparing with the previous hour. Compare with the same hour last week.
  • Looking for declined cards in transactions. With no order, you only see them as abandoned checkouts, without the reason and after 10 minutes.
  • Measuring up to the current minute. Recent checkouts do not count as abandoned yet.
  • Trusting the cron blindly. GitHub can delay or drop runs; check the Actions tab on the first day.
  • Probing a product that can sell out, or leaving the Slack URL in the code. The first causes false alarms; the second leaks a secret.

Frequently asked questions

Why not use webhooks instead of polling every 10 minutes?

A webhook tells you something happened, and these alerts look for something that stopped happening: if the checkout goes down, no order webhook arrives. order_transactions/create, which per the webhook topic list only fires for transactions with a success, failure or error status, helps you react to each failure, but you still need a clock.

My store only gets a few orders an hour. Is this still useful?

Alert 1 stays quiet while that hour last week had fewer than 10 orders. Widen the window or lower MIN_BASELINE, accepting more false alarms. Alert 3 does not depend on volume, so it protects a small store the most.

Can I run it without GitHub Actions?

Yes. It uses the built-in fetch of Node 18 or later and runs on any computer or server with cron, with the same line and the same environment variables. Outside GitHub, exit code 1 no longer emails you, so rely on the Slack message.

Does the checkout probe pollute my reports?

It creates about 144 carts a day and no orders. Since it enters no contact details, it does not meet the definition of an abandoned checkout. We did not verify whether Shopify counts those visits in its session reports: check them after the first day and, if they get in the way, space out the cron.

Checklist

  • The app has read_orders and the script gets its token without errors.
  • The API version is 2026-10 or a later stable one.
  • Alert 1 compares with the same hour last week and requires a minimum number of orders.
  • Alert 2 counts failed transactions and the abandoned share, with the window ending 15 minutes back.
  • The probe variant for alert 3 will not sell out.
  • The cron skips minute 0, secrets stay out of the code and workflow_dispatch is there.
  • You forced an alert and both the Slack message and the email arrived.

With these three checkout alerts, a failure on a sale day costs you minutes instead of an afternoon. Before the sale, run the checkout smoke test and freeze changes. And if your analytics numbers do not match Shopify's afterward, read why GA4 and Shopify sales don't match.

Before Black Friday, also check when your abandoned cart emails go out and what to freeze in your code.

Saw this on Instagram? Comment MONITOREO on the Reel and I'll send you the guide.

Written by

Luis Morales

Luis Morales

Frontend and Shopify developer, EcomLabs

@luismoralesdev on Instagram

Published November 11, 2026 · updated November 18, 2026

← Blog