Whale Traffic

Tools05 Conversion drop alert

Know the day your tracking breaks.

When a conversion tag breaks, clicks carry on, conversions stop, and automated bidding starts learning from bad data. This script compares yesterday with the same weekday over the last four weeks and emails you when conversions fall while clicks hold.

Get the script

Free Google Ads script · Reads only

What it reports

What you get back.

Best run · Daily, in the morning

  1. 01

    Yesterday’s clicks, cost, and conversions beside the usual for that weekday.

  2. 02

    A warning when conversions fall sharply while clicks hold.

  3. 03

    A warning when clicks collapse or spend jumps.

The script.

Copy all of it into a new script in Google Ads. The settings sit in the first few lines.

conversion-drop-alert.js · 76 lines

const CONFIG = {
  WEEKS: 4,
  DROP: 0.6,
  MIN_CLICKS: 50,
  MIN_CONVERSIONS: 5,
  EMAIL: "",
};

function main() {
  const account = AdsApp.currentAccount();
  const currency = account.getCurrencyCode();
  const zone = account.getTimeZone();
  const day = 24 * 60 * 60 * 1000;
  const yesterday = Date.now() - day;
  const dates = [];
  for (let week = 0; week <= CONFIG.WEEKS; week++) {
    dates.push(Utilities.formatDate(new Date(yesterday - week * 7 * day), zone, "yyyy-MM-dd"));
  }

  const rows = AdsApp.search(
    "SELECT segments.date, metrics.clicks, metrics.cost_micros, metrics.conversions " +
      "FROM customer " +
      "WHERE segments.date BETWEEN '" + dates[dates.length - 1] + "' AND '" + dates[0] + "'"
  );
  const days = new Map();
  while (rows.hasNext()) {
    const row = rows.next();
    days.set(row.segments.date, {
      clicks: Number(row.metrics.clicks),
      cost: Number(row.metrics.costMicros) / 1e6,
      conversions: Number(row.metrics.conversions),
    });
  }

  const empty = { clicks: 0, cost: 0, conversions: 0 };
  const latest = days.get(dates[0]) || empty;
  const usual = { clicks: 0, cost: 0, conversions: 0 };
  dates.slice(1).forEach((date) => {
    const past = days.get(date) || empty;
    usual.clicks += past.clicks / CONFIG.WEEKS;
    usual.cost += past.cost / CONFIG.WEEKS;
    usual.conversions += past.conversions / CONFIG.WEEKS;
  });

  const keep = 1 - CONFIG.DROP;
  const problems = [];
  if (usual.conversions >= CONFIG.MIN_CONVERSIONS && latest.clicks >= CONFIG.MIN_CLICKS && latest.conversions < usual.conversions * keep) {
    problems.push(
      "Conversions fell to " + round(latest.conversions) + " from a usual " + round(usual.conversions) +
        " while clicks held at " + latest.clicks + ". Check the conversion tag before anything else."
    );
  }
  if (usual.clicks >= CONFIG.MIN_CLICKS && latest.clicks < usual.clicks * keep) {
    problems.push("Clicks fell to " + latest.clicks + " from a usual " + round(usual.clicks) + ". Check for paused campaigns, disapproved ads, or a billing hold.");
  }
  if (usual.cost > 0 && latest.cost > usual.cost * (1 + CONFIG.DROP)) {
    problems.push("Spend rose to " + currency + " " + round(latest.cost).toFixed(2) + " from a usual " + currency + " " + round(usual.cost).toFixed(2) + ".");
  }

  const summary = [
    account.getName() + ", " + dates[0] + " against the same weekday in the " + CONFIG.WEEKS + " weeks before",
    "Clicks " + latest.clicks + " (usual " + round(usual.clicks) + ")",
    "Cost " + currency + " " + round(latest.cost).toFixed(2) + " (usual " + currency + " " + round(usual.cost).toFixed(2) + ")",
    "Conversions " + round(latest.conversions) + " (usual " + round(usual.conversions) + ")",
  ];
  const lines = summary.concat([""], problems.length ? problems : ["Nothing unusual."]);

  lines.forEach((line) => Logger.log(line));
  if (problems.length && CONFIG.EMAIL) {
    MailApp.sendEmail(CONFIG.EMAIL, "Check " + account.getName() + ": " + problems.length + " warning" + (problems.length > 1 ? "s" : ""), lines.join("\n"));
  }
}

function round(value) {
  return Math.round(value * 100) / 100;
}

Settings

WEEKSStarts at 4
How many earlier weeks make up the usual figure.
DROPStarts at 0.6
How far from usual counts as a warning. 0.6 means 60%.
MIN_CLICKSStarts at 50
The fewest clicks before a day is judged.
MIN_CONVERSIONSStarts at 5
The smallest usual daily conversions before the conversion check runs.
EMAILStarts empty
Where to send the summary. Leave it empty to skip.

How to install

  1. 01

    Open Scripts

    In Google Ads, open Tools, then Bulk actions, then Scripts.

  2. 02

    Paste it in

    Press the plus button, choose New script, and paste the script over the sample code.

  3. 03

    Set the values

    Edit the settings at the top. Add a Google Sheet link or an email address if you want the report sent somewhere.

  4. 04

    Preview, then schedule

    Authorize the script, press Preview to read the report in the log, then save it and choose how often it runs.

Good to know

  • If your conversions arrive days after the click, yesterday will always look low. Raise DROP, or leave this script out.
  • It emails only when there is a warning. The log shows the figures on every run.
  • It judges the whole account. A break in one small campaign can hide inside a normal total.

Free to use and to change. The script only reads your account. It is provided as it is, with no warranty, so run Preview before you schedule it.

Work with us

Tell us what you’re trying to grow.

Start with a quick conversation about your goals and current spend. We’ll come back with a plan and a straight answer on whether we’re the right fit.

Request a proposal