Budgets

Set campaign budget

function setCampaignBudget() {
  var campaignIterator = AdWordsApp.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 = AdWordsApp.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());
    }
  }
}

发送以下问题的反馈:

此网页
AdWords Scripts
AdWords Scripts
需要帮助?请访问我们的支持页面