Pause campaign when monthly budget is reached

This script pauses campaigns in a strategy when the budget specified in the dimension is reached.

What can I do with this?

This script gives you greater control of monthly spending than publisher tools allow, eliminating the possibility of overspending and client credits.

How it works

This script compares the MTD spend and if it's within the safety margin of the monthly target it pauses the campaign and outputs the pause date to a dimension.

  • The script automatically pauses PPC campaigns that exceed their monthly budget caps.
  • It identifies campaigns that have spent more than their allocated budget and pauses them to prevent overspending.
  • The script will reactivate the campaigns it has paused on the first of the following month.
  • The script is designed to be run periodically to ensure budgets are not exceeded.


  • Ensure you have intraday-data turned on. Contact your Marin team for help.
  • Requires several Dimensions to store campaign budget and related information. See code below for full list.
  • Select This Month as the date range with Include Today's Date checked
  • Schedule report to run every two hours. 
  • Script will run in “preview” mode by default.
    • When running in preview mode only the “SBA Recommended Status” field will be updated.
  • If the dimension field “SBA Traffic” is set to a value of “Traffic” for a campaign the script will sync with the publisher to change the status of campaigns (either “Pause” or “Active”)
    • When in traffic mode the script will set the SBA Recommended Status, SBA Pause Date and Campaign Status fields


  • Adjust Budget Cap Safety Margin


Written by Wes MacLaggan

Last published at: March 25th, 2024