cov19 icon
COVID-19 COMPANY UPDATE
We are 100% available for you and provide strategic advice on how your business can cope with uncertainty these days.

Budget Eater Script

Script to evaluate your long tail and identify non-converters

Budget Eater Script illustration

Ready to learn more about your long tail and non-converters?

The “Budget Eater” script evaluates the long tail and non-converters of the last 30 days. It will analyse your Google Shopping campaigns and provide you with insights about the correlations between costs, conversions and the long tail. Furthermore, you will get impressions regarding the contribution of your long tail to your conversions. Just add the script to your Google Ads account and get your results. The code won’t change anything in your campaigns, it just analyses your existing data and provides you with an automatic evaluation.

You can find a detailed description and learn how to use this script in our blog: Google Shopping and the Long Tail

Download script and start optimizing

No commitments & no hidden costs — Just a great script

Access and read our privacy policy.

Success image

Thank you!

You can get the script code below

Arrow down icon
/**
 * Budget Eater Script         . * ・ 。゚☆━੧[ ✪ ᗜ ✪ ]⊃
 *
 * Overview: You can use this script to evaluate your Long Tail and your
 * non-converters from the last 30 days. The script will give you an impression
 * of the correlations between costs, conversions, and the Long Tail within
 * your account.
 *
 * Author: smec Team [smarter-ecommerce.com]
 *
 * Version: 1.0
 * Changelog:
 * - version 1.0
 *  - Released initial version.
 * Updated: 27-04-2018
 *
 * Twitter: @smec
 * Email: [email protected]
 * (c) Smarter Ecommerce GmbH. All rights reserved.
 * License: MIT
 */

/* ============================== Preferences =============================== */

// Sets the number of conversions threshold for evaluating the Long Tail.
var LONG_TAIL_CONVERSIONS_THRESHOLD = 3;

var TIME_RANGE = "LAST_30_DAYS";

/* =============================== Execution ================================ */

function main() {
  // Select cost and conversions for all products during the last 30 days.
  var report = AdWordsApp.report(
      "SELECT OfferId, Cost, Conversions, ConversionValue, Impressions " +
      "FROM SHOPPING_PERFORMANCE_REPORT " +
      "DURING "+ TIME_RANGE);

  var result = {
      nonConverters: { count: 0, cost: 0 },
      longtail: { count: 0, cost: 0, conversions: 0, conversionValue: 0 },
      converters: { count: 0, cost: 0, conversions: 0, conversionValue: 0 }
  };

  // Iterate through all rows and categorize each product by the number of its conversions.
  var rows = report.rows();

  while (rows.hasNext()) {
    var row = rows.next();
    var conversions = parseFloat(row['Conversions'], 10);
    var cost = parseFloat(row['Cost'], 10);
    var conversionValue = parseFloat(row['ConversionValue'], 10);

    if (conversions < 1) {
        result.nonConverters.count += 1;
        result.nonConverters.cost += cost;
    } else if (conversions < LONG_TAIL_CONVERSIONS_THRESHOLD) {
        result.longtail.count += 1;
        result.longtail.conversions += conversions;
        result.longtail.cost += cost;
        result.longtail.conversionValue += conversionValue;
    } else {
        result.converters.count += 1;
        result.converters.cost += cost;
        result.converters.conversions += conversions;
        result.converters.conversionValue += conversionValue;
    }
  }

  var totalCost = result.nonConverters.cost + result.longtail.cost + result.converters.cost;
  var totalConversions = result.longtail.conversions + result.converters.conversions;
  var totalConversionValue = result.longtail.conversionValue + result.converters.conversionValue;

  // In this part, the calculated result numbers are printed:
  Logger.log("Shopping Ads (last 30 days)");
  Logger.log("---------------------------\n");
  Logger.log("Number of products without conversions: " + result.nonConverters.count);
  Logger.log("Number of products in Long Tail: " + result.longtail.count);
  Logger.log("Number of products having at least 3 conversions: " + result.converters.count + "\n");
  Logger.log("Total cost: " + round(totalCost));
  Logger.log("Cost for Non-Converters: " + round(result.nonConverters.cost) +
      " (" + round(percentage(result.nonConverters.cost, totalCost)) + "% from total cost)\n");
  Logger.log("Total conversion value: " + round(totalConversionValue));
  Logger.log("ROAS for Long Tail: " + round(result.longtail.conversionValue / result.longtail.cost) + "\n");
  Logger.log("Total conversions: " + round(totalConversions));
  Logger.log("Conversions from Long Tail: " + round(result.longtail.conversions) +
      " (" + round(percentage(result.longtail.conversions, totalConversions)) + "% from total conversions)");
}

/**
 * A helper function which rounds the given number to 2 decimals.
 */
function round(number) {
  return Math.round(number * 100) / 100;
}

/**
 * A helper function which returns the percentage of a value for the given total value.
 */
function percentage(value, total) {
  return value / total * 100;
}

The code was successfully copied to your Clipboard.

Popular Google Ads Scripts

Martin Röttgerding

“Automation can take your PPC efforts to the next level – if you’re doing it right.”

Martin Röttgerding, Head of SEA – Bloofusion Germany

Maximize your Google Shopping performance with Whoop!

Get in touch to learn more