Budget Eater Script

A Script to Evaluate Your Long Tail and Identify Non-Converters from the Last 30 Days

Want to Know More about Your Long Tail and Non-Converters?

The Budget Eater script assesses your Long Tail and identifies your non-converters from the last 30 days. Just add the script to your AdWords account to get your results. The code won’t change any settings in your AdWords campaigns: it just analyzes 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

Budget Eater image asset

Note: Required fields are marked with (*).

/**
	* Budget Eater Script
	* Description: 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.

	* (c) whoopapp.com by smarter-ecommerce.com
	* More information about the Long Tail and how to use this script:
	* https://whoopapp.com/blog/budget-eater-script
	* Twitter: @whoop_app
	* Email: hello@whoopapp.com
*/

/**
 * 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;
}


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 LAST_30_DAYS");

    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 < 3) {
            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)");
}

The code was copied successfully to your Clipboard.

Start Boosting Your Google Shopping Performance Today

TRY IT NOW! Whoop! will create a new shopping campaign. So don't worry,
you can switch back to your previous settings any time.