This is the legacy documentation for Google Ads scripts. Go to the current docs.

Budgets

Stay organized with collections Save and categorize content based on your preferences.

Set campaign budget

function setCampaignBudget() {
  var campaignIterator = AdsApp.campaigns()
      .withCondition('Name = "INSERT_CAMPAIGN_NAME_HERE"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    campaign.getBudget().setAmount(100);
    Logger.log('Campaign with name = ' + campaign.getName() +
        ' has budget = ' + campaign.getBudget().getAmount());
  }
}

Get campaign budget

function getBudgetDetails() {
  var campaignIterator = AdsApp.campaigns()
      .withCondition('Name = "INSERT_CAMPAIGN_NAME_HERE"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    var budget = campaign.getBudget();
    var budgetCampaignIterator = budget.campaigns().get();

    Logger.log('Budget amount : ' + budget.getAmount());
    Logger.log('Delivery method : ' + budget.getDeliveryMethod());
    Logger.log('Explicitly shared : ' + budget.isExplicitlyShared());
    Logger.log('Associated campaigns : ' +
        budgetCampaignIterator.totalNumEntities());
    Logger.log('Details');
    Logger.log('=======');

    // Get all the campaigns associated with this budget. There could be
    // more than one campaign if this is a shared budget.

    while (budgetCampaignIterator.hasNext()) {
      var associatedCampaign = budgetCampaignIterator.next();
      Logger.log(associatedCampaign.getName());
    }
  }
}