帳戶預算

帳戶預算可定義支出上限、開始時間和結束時間等預算屬性,藉此控管帳戶在特定時間內可以支出的內容。他們必須指向帳戶的其中一個帳單設定,才指明要向哪個付款帳戶收費。您可以透過傳送 AccountBudgetProposal 物件來建立、更新及移除 AccountBudget

AccountBudget 物件代表套用提案的最終結果。提案獲得核准後,提案的變更 (視任何調整而定) 可能會導致建立新的帳戶預算,或更新現有的預算。這取決於要求中指定的 proposal_type

AccountBudgetProposalType 說明
CREATE 建立新的帳戶預算,必須經過核准才能使用。
UPDATE 修改現有帳戶預算。
END 將帳戶預算的結束時間設為目前時間。
REMOVE 在開始時間前移除帳戶預算。

以下各節說明各種提案類型的行為。

建立帳戶預算提案

建立新的帳戶預算可讓您控管客戶的支出行為。使用 AccountBudgetProposalService 建立新的 AccountBudgetProposal。您應將 proposal_type 設為 CREATE,以指定應建立新預算。如要瞭解其他作業,請參閱本指南的管理一節。

請務必透過您擁有寫入存取權的付款帳戶使用帳單設定。詳情請參閱帳單設定指南

以下範例說明如何建立新的預算提案。

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId, long billingSetupId) {
  // Creates an AccountBudgetProposal. This will be reviewed offline by Google Ads, and if
  // approved will become an AccountBudget.
  AccountBudgetProposal proposal =
      AccountBudgetProposal.newBuilder()
          .setBillingSetup(ResourceNames.billingSetup(customerId, billingSetupId))
          .setProposalType(AccountBudgetProposalType.CREATE)
          .setProposedName("Account Budget (example)")

          // Specifies the account budget starts immediately.
          .setProposedStartTimeType(TimeType.NOW)
          // Alternatively you can specify a specific start time. Refer to the
          // AccountBudgetProposal
          // resource documentation for allowed formats.
          //
          // .setProposedStartDateTime("2020-01-02 03:04:05")

          // Specifies that the budget runs forever.
          .setProposedEndTimeType(TimeType.FOREVER)
          // Alternatively you can specify a specific end time. Allowed formats are as above.
          // .setProposedEndDateTime("2021-02-03 04:05:06")

          // Optional: sets notes for the budget. These are free text and do not effect budget
          // delivery.
          // .setProposedNotes("Received prepayment of $0.01")

          // Sets the spending limit to 0.01, measured in the Google Ads account currency.
          .setProposedSpendingLimitMicros(10_000)

          // Optional: sets PO number for record keeping. This value is at the user's
          // discretion, and has no effect on Google Billing & Payments.
          // .setProposedPurchaseOrderNumber("PO number 12345")
          .build();

  // Creates an operation which will add the new AccountBudgetProposal.
  AccountBudgetProposalOperation operation =
      AccountBudgetProposalOperation.newBuilder().setCreate(proposal).build();

  try (AccountBudgetProposalServiceClient accountBudgetProposalServiceClient =
      googleAdsClient.getLatestVersion().createAccountBudgetProposalServiceClient()) {
    // Sends the request to the Account Budget Proposal Service.
    MutateAccountBudgetProposalResponse response =
        accountBudgetProposalServiceClient.mutateAccountBudgetProposal(
            String.valueOf(customerId), operation);

    System.out.printf(
        "Account budget proposal created: %s.%n", response.getResult().getResourceName());
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId, long billingSetupId)
{
    // Get the AccountBudgetProposalServiceClient.
    AccountBudgetProposalServiceClient proposalService =
        client.GetService(Services.V16.AccountBudgetProposalService);

    // Create an AccountBudgetProposal. The proposal will be reviewed offline by Google Ads,
    // and if approved will become an AccountBudget.
    AccountBudgetProposal proposal = new AccountBudgetProposal()
    {
        BillingSetup = ResourceNames.BillingSetup(customerId, billingSetupId),
        ProposalType = AccountBudgetProposalType.Create,
        ProposedName = "Account Budget (example)",

        // Specify the account budget starts immediately
        ProposedStartTimeType = TimeType.Now,
        // Alternatively, you can specify a specific start time. Refer to the
        // AccountBudgetProposal resource documentation for allowed formats.
        //
        //ProposedStartDateTime = "2020-01-02 03:04:05",

        // Specify that the budget runs forever.
        ProposedEndTimeType = TimeType.Forever,
        // Alternatively you can specify a specific end time. Allowed formats are as above.
        //ProposedEndDateTime = "2021-02-03 04:05:06",

        // Optional: set notes for the budget. These are free text and do not effect budget
        // delivery.
        //ProposedNotes = "Received prepayment of $0.01",

        // Set the spending limit to 0.01, measured in the Google Ads account currency.
        ProposedSpendingLimitMicros = 10_000

        // Optional: set PO number for record keeping. This value is at the user's
        // discretion, and has no effect on Google Billing & Payments.
        //ProposedPurchaseOrderNumber = "PO number 12345"
    };

    // Create an operation which will add the new AccountBudgetProposal
    AccountBudgetProposalOperation operation = new AccountBudgetProposalOperation()
    {
        Create = proposal
    };

    try
    {
        // Send the request to the Account Budget Proposal Service.
        MutateAccountBudgetProposalResponse response = proposalService.
            MutateAccountBudgetProposal(customerId.ToString(), operation);

        // Display the results.
        Console.WriteLine($"Account budget proposal '{response.Result.ResourceName}' " +
            "was created.");
    }
    catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }
}
      

PHP

public static function runExample(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $billingSetupId
) {
    // Constructs an account budget proposal.
    $accountBudgetProposal = new AccountBudgetProposal([
        'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId),
        'proposal_type' => AccountBudgetProposalType::CREATE,
        'proposed_name' => 'Account Budget (example)',
        // Specifies the account budget starts immediately.
        'proposed_start_time_type' => TimeType::NOW,
        // Alternatively you can specify a specific start time. Refer to the
        // AccountBudgetProposal class for allowed formats.
        //
        // 'proposed_start_date_time' => '2020-01-02 03:04:05',

        // Specify that the budget runs forever.
        'proposed_end_time_type' => TimeType::FOREVER,
        // Alternatively you can specify a specific end time. Allowed formats are as above.
        // 'proposed_end_date_time' => '2021-02-03 04:05:06',

        // Optional: set notes for the budget. These are free text and do not effect budget
        // delivery.
        // 'proposed_notes' => 'Received prepayment of $0.01',

        // Optional: set PO number for record keeping. This value is at the user's
        // discretion, and has no effect on Google Billing & Payments.
        // 'proposed_purchase_order_number' => 'PO number 12345',

        // Set the spending limit to 0.01, measured in the Google Ads account currency.
        'proposed_spending_limit_micros' => 10000
    ]);

    $accountBudgetProposalOperation = new AccountBudgetProposalOperation();
    $accountBudgetProposalOperation->setCreate($accountBudgetProposal);

    // Issues a mutate request to add the account budget proposal.
    $accountBudgetProposalServiceClient =
        $googleAdsClient->getAccountBudgetProposalServiceClient();
    $response = $accountBudgetProposalServiceClient->mutateAccountBudgetProposal(
        MutateAccountBudgetProposalRequest::build($customerId, $accountBudgetProposalOperation)
    );

    printf(
        "Added an account budget proposal with resource name '%s'.%s",
        $response->getResult()->getResourceName(),
        PHP_EOL
    );
}
      

Python

def main(client, customer_id, billing_setup_id):
    account_budget_proposal_service = client.get_service(
        "AccountBudgetProposalService"
    )
    billing_setup_service = client.get_service("BillingSetupService")

    account_budget_proposal_operation = client.get_type(
        "AccountBudgetProposalOperation"
    )
    proposal = account_budget_proposal_operation.create

    proposal.proposal_type = client.enums.AccountBudgetProposalTypeEnum.CREATE
    proposal.billing_setup = billing_setup_service.billing_setup_path(
        customer_id, billing_setup_id
    )
    proposal.proposed_name = "Account Budget Proposal (example)"

    # Specify the account budget starts immediately
    proposal.proposed_start_time_type = client.enums.TimeTypeEnum.NOW
    # Alternatively you can specify a specific start time. Refer to the
    # AccountBudgetProposal resource documentation for allowed formats.
    #
    # proposal.proposed_start_date_time = '2020-01-02 03:04:05'

    # Specify that the budget runs forever
    proposal.proposed_end_time_type = client.enums.TimeTypeEnum.FOREVER
    # Alternatively you can specify a specific end time. Allowed formats are as
    # above.
    #
    # proposal.proposed_end_date_time = '2021-01-02 03:04:05'

    # Optional: set notes for the budget. These are free text and do not effect
    # budget delivery.
    #
    # proposal.proposed_notes = 'Received prepayment of $0.01'
    proposal.proposed_spending_limit_micros = 10000

    account_budget_proposal_response = (
        account_budget_proposal_service.mutate_account_budget_proposal(
            customer_id=customer_id,
            operation=account_budget_proposal_operation,
        )
    )
    print(
        "Created account budget proposal "
        f'"{account_budget_proposal_response.result.resource_name}".'
    )
      

Ruby

def add_account_budget_proposal(customer_id, billing_setup_id)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new


  operation = client.operation.create_resource.account_budget_proposal do |proposal|
    proposal.billing_setup = client.path.billing_setup(customer_id, billing_setup_id)
    proposal.proposal_type = :CREATE
    proposal.proposed_name = 'Account Budget (example)'

    # Specify the account budget starts immediately
    proposal.proposed_start_time_type = :NOW
    # Alternatively you can specify a specific start time. Refer to the
    # AccountBudgetProposal resource documentation for allowed formats.
    #
    # proposal.proposed_start_date_time = '2020-01-02 03:04:05'

    # Specify that the budget runs forever.
    proposal.proposed_end_time_type = :FOREVER
    # Alternatively you can specify a specific end time. Allowed formats are as
    # above.
    #
    # proposal.proposed_end_date_time = '2021-01-02 03:04:05'

    # Optional: set notes for the budget. These are free text and do not affect
    # budget delivery.
    #
    # proposal.proposed_notes = 'Received prepayment of $0.01'

    # Set the spending limit to 0.01, measured in the Google Ads account currency.
    proposal.proposed_spending_limit_micros = 10_000
  end

  account_budget_proposal_service = client.service.account_budget_proposal
  # Add budget proposal.
  response = account_budget_proposal_service.mutate_account_budget_proposal(
    customer_id: customer_id,
    operation: operation,
  )

  puts sprintf("Created budget proposal %s.",
      response.results.first.resource_name)
end
      

Perl

sub add_account_budget_proposal {
  my ($api_client, $customer_id, $billing_setup_id) = @_;

  # Create an account budget proposal.
  my $account_budget_proposal =
    Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
      billingSetup =>
        Google::Ads::GoogleAds::V16::Utils::ResourceNames::billing_setup(
        $customer_id, $billing_setup_id
        ),
      proposalType => CREATE,
      proposedName => "Account Budget (example)",
      # Specify that the account budget starts immediately.
      proposedStartTimeType => NOW,
      # Alternatively you can specify a specific start time. Refer to the
      # AccountBudgetProposal class for allowed formats.
      #
      # proposedStartDateTime => "2020-01-02 03:04:05",

      # Specify that the account budget runs forever.
      proposedEndDateTime => FOREVER,
      # Alternatively you can specify a specific end time. Allowed formats are as below.
      # proposedEndDateTime => "2021-02-03 04:05:06",

      # Optional: set notes for the budget. These are free text and do not effect budget
      # delivery.
      # proposedNotes => "Received prepayment of $0.01",

      # Optional: set PO number for record keeping. This value is at the user's
      # discretion, and has no effect on Google Billing & Payments.
      # proposedPurchaseOrderNumber => "PO number 12345",

      # Set the spending limit to 0.01, measured in the Google Ads account currency.
      proposedSpendingLimitMicros => 10000
    });

  # Create an account budget proposal operation.
  my $account_budget_proposal_operation =
    Google::Ads::GoogleAds::V16::Services::AccountBudgetProposalService::AccountBudgetProposalOperation
    ->new({
      create => $account_budget_proposal
    });

  # Add the account budget proposal.
  my $account_budget_proposal_response =
    $api_client->AccountBudgetProposalService()->mutate({
      customerId => $customer_id,
      operation  => $account_budget_proposal_operation
    });

  printf "Created account budget proposal '%s'.\n",
    $account_budget_proposal_response->{result}{resourceName};

  return 1;
}
      

在帳戶預算提案請求中,proposed_start_date_timeproposed_end_date_time 一律會採用客戶帳戶的時區。您無法指定時區。系統一律會以帳戶貨幣計算提議的支出上限。請使用「微量」單位來指定,因此 $1.00 = 1,000,000 微量。

您可以視需要加入訂購單號碼,這個號碼會顯示在應付憑據上的這些費用旁邊。這不會影響預算放送。

移除待處理的帳戶預算提案

如要移除整個待處理的預算提案,請傳送 AccountBudgetProposalOperation Remove 要求並附上帳戶預算提案資源名稱。不過請注意,預算提案通常會在幾分鐘內套用。

Java
AccountBudgetProposalOperation operation = AccountBudgetProposalOperation.newBuilder()
  .setRemove(StringValue.of(ResourceNames.accountBudgetProposal(customerId, accountBudgetProposalId)))
  .build();

// Send request to Google Ads API (not shown).
C#
AccountBudgetProposalOperation operation = new AccountBudgetProposalOperation()
{
    Remove = ResourceNames.AccountBudgetProposal(customerId, accountBudgetProposalId)
};

// Send request to Google Ads API (not shown).
PHP
$accountBudgetProposalOperation = new AccountBudgetProposalOperation();
$accountBudgetProposalOperation->setRemove(ResourceNames::forAccountBudgetProposal($customerId, $accountBudgetProposalId));

// Send request to Google Ads API (not shown).
Python
account_budget_proposal_service = client.get_service('AccountBudgetProposalService')
account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposal = account_budget_proposal_operation.remove
proposal.resource_name = account_budget_proposal_service.account_budget_proposal_path(customer_id, account_budget_proposal_id):

# Send request to Google Ads API (not shown).
Ruby
operation = client.operation.remove_resource.account_budget_proposal(client.path.account_budget_proposal(customer_id, account_budget_proposal_id))

# Send request to Google Ads API (not shown).
Perl
my $account_budget_proposal_operation =
  Google::Ads::GoogleAds::V16::Services::AccountBudgetProposalService::AccountBudgetProposalOperation
    ->new({
      remove => Google::Ads::GoogleAds::V16::Utils::ResourceNames::billing_setup(
          $customer_id, $account_budget_proposal_id
        )
    });

# Send request to Google Ads API (not shown).

如果原本的提案有誤,可以以 UPDATE 作業的形式重新提交提案。詳情請參閱下方的「管理現有帳戶預算」一節。

擷取現有帳戶預算

以下 GAQL 查詢會擷取帳戶中所有現有的帳戶預算:

SELECT
  account_budget.status,
  account_budget.billing_setup,
  account_budget.approved_spending_limit_micros,
  account_budget.approved_spending_limit_type,
  account_budget.proposed_spending_limit_micros,
  account_budget.proposed_spending_limit_type,
  account_budget.adjusted_spending_limit_micros,
  account_budget.adjusted_spending_limit_type,
  account_budget.approved_start_date_time,
  account_budget.proposed_start_date_time,
  account_budget.approved_end_date_time,
  account_budget.approved_end_time_type,
  account_budget.proposed_end_date_time,
  account_budget.proposed_end_time_type
FROM
  account_budget

請注意,封裝帳戶預算的開始時間、結束時間和支出限制的欄位,且包含多個變化版本 (例如 proposedapproved),可比較最初提議的值與已核准的值。支出上限部分含有 adjusted 前置字串,表示目前將任何調整套用至已核准的金額後,目前有效的支出上限。

也可以不時調整帳戶預算的支出上限,藉此反映預算超量放送、無效點擊活動和促銷優待券等多種抵免額。如要進一步瞭解帳戶預算帳戶抵免額和調整項,請前往 Google Ads 說明中心。

任何待核准的帳戶預算,以及有待更新的所有現有帳戶預算,也都會包含可選取的 pending_proposal 欄位。其中包含相關聯 AccountBudgetProposal 物件的資源 ID

程式碼範例

每個用戶端程式庫Billing 資料夾都有提供完整要求的程式碼範例:

管理現有帳戶預算

為客戶建立帳戶預算後,您可以使用 AccountBudgetProposalService 管理預算參數。最常見的管理作業是更新 spending_limitend_date_time 欄位。如需可變動欄位的完整清單,請參閱 AccountBudgetProposal 文件。

您可以選擇更新現有的帳戶預算,或是建立全新的預算,兩者都會顯示。

更新現有帳戶預算

您可以傳送 AccountBudgetProposal 物件,並將 AccountBudgetProposalType 設為 UPDATE,藉此更新現有帳戶預算欄位。請注意,您還必須在作業的 UpdateMask 引數中指定要更新的欄位。

以下程式碼片段示範如何為現有帳戶預算更新提議的支出上限。

Java
AccountBudgetProposal proposal = AccountBudgetProposal.newBuilder()
  .setProposalType(AccountBudgetProposalType.UPDATE)
  .setAccountBudget(accountBudget.getResourceName())
  .setProposedSpendingLimitMicros(
    accountBudget.getProposedSpendingLimitMicros().getValue() + increaseAmount)
  .build();

AccountBudgetProposalOperation operation = AccountBudgetProposalOperation.newBuilder()
  .setCreate(proposal)
  .setUpdateMask(
      FieldMask.newBuilder().addAllPaths(Arrays.asList("proposed_spending_limit")).build())
  .build();

// Send request to Google Ads API (not shown).
C#
AccountBudgetProposal proposal = new AccountBudgetProposal()
{
  ProposalType = AccountBudgetProposalType.Update,
  AccountBudget = accountBudget.ResourceName,
  ProposedSpendingLimitMicros = accountBudget.ProposedSpendingLimitMicros + increaseAmount
};

AccountBudgetProposalOperation operation = new AccountBudgetProposalOperation()
{
  Create = proposal,
  UpdateMask = new FieldMask()
  {
    Paths = { "proposed_spending_limit" }
  }
};

// Send request to Google Ads API (not shown).
PHP
$accountBudgetProposal = new AccountBudgetProposal([
  'proposal_type' => AccountBudgetProposalType::UPDATE,
  'account_budget' => $accountBudget->getResourceName(),
  'proposed_spending_limit_micros' =>
    $accountBudget->getProposedSpendingLimitMicros() + $increaseAmount])

$accountBudgetProposalOperation = new AccountBudgetProposalOperation();
$accountBudgetProposalOperation->setCreate($accountBudgetProposal);
$accountBudgetProposalOperation->setUpdateMask(
  FieldMasks::allSetFieldsOf($accountBudgetProposal)
);

// Send request to Google Ads API (not shown).
Python
account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')

proposal = account_budget_proposal_operation.create
proposal.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').UPDATE
proposal.account_budget = account_budget
proposal.proposed_spending_limit_micros = account_budget.proposed_spending_limit_micros + increase_amount

field_mask = protobuf_helpers.field_mask(None, proposal)
account_budget_proposal_operation.update_mask.CopyFrom(field_mask)

# Send request to Google Ads API (not shown).
Ruby
proposal = client.resource.account_budget_proposal
proposal.proposal_type = :UPDATE

mask = client.field_mask.with proposal do
  proposal.account_budget = account_budget.resource_name
  proposal.proposed_spending_limit_micros = account_budget.proposed_spending_limit_micros + increase_amount
end

operation = client.operation.account_budget_proposal do |op|
  op.create = proposal
  op.update_mask = mask
end

# Send request to Google Ads API (not shown).
Perl
my $account_budget_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    proposalType => UPDATE,
    accountBudget => $account_budget->{resourceName},
    proposedSpendingLimitMicros => $account_budget->{proposedSpendingLimitMicros} + $increaseAmount});

my $account_budget_proposal_operation =
  Google::Ads::GoogleAds::V16::Services::AccountBudgetProposalService::AccountBudgetProposalOperation
    ->new({
      create => $account_budget_proposal,
      updateMask => all_set_fields_of($account_budget_proposal)});

# Send request to Google Ads API (not shown).

帳戶預算鏈結

除了更新現有預算之外,Google Ads 還可以讓您將多個帳戶預算鏈結在一起,以便連續執行。在以下範例中,客戶每個月的支出上限不同。

方法是建立三個 AccountBudgetProposal 物件,然後傳送至 AccountBudgetProposalService

以下程式碼片段示範如何使用現有帳單設定建立這類鏈結。

Java
AccountBudgetProposal proposalMay = AccountBudgetProposal.newBuilder()
  .setBillingSetup(ResourceNames.billingSetup(customerId, billingSetupId))
  .setProposalType(AccountBudgetProposalType.CREATE)
  .setProposedName("May budget")
  .setProposedStartDateTime("2018-05-01")
  .setProposedEndDateTime("2018-06-01")
  .setProposedSpendingLimitMicros(1_000_000_000L)
  .build();

AccountBudgetProposal proposalJune = AccountBudgetProposal.newBuilder()
  .setBillingSetup(ResourceNames.billingSetup(customerId, billingSetupId))
  .setProposalType(AccountBudgetProposalType.CREATE)
  .setProposedName("June budget")
  .setProposedStartDateTime("2018-06-01")
  .setProposedEndDateTime("2018-07-01")
  .setProposedSpendingLimitMicros(5_000_000_000L)
  .build();

AccountBudgetProposal proposalJuly = AccountBudgetProposal.newBuilder()
  .setBillingSetup(ResourceNames.billingSetup(customerId, billingSetupId))
  .setProposalType(AccountBudgetProposalType.CREATE)
  .setProposedName("July budget")
  .setProposedStartDateTime("2018-07-01")
  .setProposedEndDateTime("2018-08-01")
  .setProposedSpendingLimitMicros(1_000_000_000L)
  .build();

// Send request to Google Ads API (not shown).
C#
AccountBudgetProposal proposalMay = new AccountBudgetProposal()
{
  BillingSetup = ResourceNames.BillingSetup(customerId, billingSetupId),
  ProposalType = AccountBudgetProposalType.Create,
  ProposedName = "May budget",
  ProposedStartDateTime = "2018-05-01",
  ProposedEndDateTime = "2018-06-01",
  ProposedSpendingLimitMicros = 1_000_000_000
}

AccountBudgetProposal proposalJune = new AccountBudgetProposal()
{
  BillingSetup = ResourceNames.BillingSetup(customerId, billingSetupId),
  ProposalType = AccountBudgetProposalType.Create,
  ProposedName = "June budget",
  ProposedStartDateTime = "2018-06-01",
  ProposedEndDateTime = "2018-07-01",
  ProposedSpendingLimitMicros = 5_000_000_000
}

AccountBudgetProposal proposalJuly = new AccountBudgetProposal()
{
  BillingSetup = ResourceNames.BillingSetup(customerId, billingSetupId),
  ProposalType = AccountBudgetProposalType.Create,
  ProposedName = "July budget",
  ProposedStartDateTime = "2018-07-01",
  ProposedEndDateTime = "2018-08-01",
  ProposedSpendingLimitMicros = 1_000_000_000
}

// Send request to Google Ads API (not shown).
PHP
$proposalMay = new AccountBudgetProposal([
  'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId),
  'proposal_type' => AccountBudgetProposalType::CREATE,
  'proposed_name' => 'May budget',
  'proposed_start_date_time' => '2018-05-01',
  'proposed_end_date_time' => '2018-06-01',
  'proposed_spending_limit_micros' => 1000000000
]);

$proposalJune = new AccountBudgetProposal([
  'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId),
  'proposal_type' => AccountBudgetProposalType::CREATE,
  'proposed_name' => 'June budget',
  'proposed_start_date_time' => '2018-06-01',
  'proposed_end_date_time' => '2018-07-01',
  'proposed_spending_limit_micros' => 5000000000
]);

$proposalJuly = new AccountBudgetProposal([
  'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId),
  'proposal_type' => AccountBudgetProposalType::CREATE,
  'proposed_name' => 'July budget',
  'proposed_start_date_time' => '2018-07-01',
  'proposed_end_date_time' => '2018-08-01',
  'proposed_spending_limit_micros' => 1000000000
]);

// Send request to Google Ads API (not shown).
Python
may_account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposalMay = may_account_budget_proposal_operation.create
proposalMay.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').CREATE
proposalMay.billing_setup = billing_setup_service.billing_setup_path(customer_id, billing_setup_id)
proposalMay.proposed_name = 'May budget'
proposalMay.proposed_start_date_time = '2018-05-01'
proposalMay.proposed_end_date_time = '2018-06-01'
proposalMay.proposed_spending_limit_micros = 1000000000

june_account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposalJune = may_account_budget_proposal_operation.create
proposalJune.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').CREATE
proposalJune.billing_setup = billing_setup_service.billing_setup_path(customer_id, billing_setup_id)
proposalJune.proposed_name = 'June budget'
proposalJune.proposed_start_date_time = '2018-06-01'
proposalJune.proposed_end_date_time = '2018-07-01'
proposalJune.proposed_spending_limit_micros = 5000000000

july_account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposalJuly = may_account_budget_proposal_operation.create
proposalJuly.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').CREATE
proposalJuly.billing_setup = billing_setup_service.billing_setup_path(customer_id, billing_setup_id)
proposalJuly.proposed_name = 'July budget'
proposalJuly.proposed_start_date_time = '2018-07-01'
proposalJuly.proposed_end_date_time = '2018-08-01'
proposalJuly.proposed_spending_limit_micros = 1000000000

# Send request to Google Ads API (not shown).
Ruby
proposal_may = client.operation.create_resource.account_budget_proposal do |proposal|
  proposal.billing_setup = client.path.billing_setup(customer_id, billing_setup_id)
  proposal.proposal_type = :CREATE
  proposal.proposed_name = 'May budget'
  proposal.proposed_start_date_time = '2018-05-01'
  proposal.proposed_end_date_time = '2018-06-01'
  proposal.proposed_spending_limit_micros = 1_000_000_000
end

proposal_june = client.operation.create_resource.account_budget_proposal do |proposal|
  proposal.billing_setup = client.path.billing_setup(customer_id, billing_setup_id)
  proposal.proposal_type = :CREATE
  proposal.proposed_name = 'June budget'
  proposal.proposed_start_date_time = '2018-06-01'
  proposal.proposed_end_date_time = '2018-07-01'
  proposal.proposed_spending_limit_micros = 5_000_000_000
end

proposal_july = client.operation.create_resource.account_budget_proposal do |proposal|
  proposal.billing_setup = client.path.billing_setup(customer_id, billing_setup_id)
  proposal.proposal_type = :CREATE
  proposal.proposed_name = 'July budget'
  proposal.proposed_start_date_time = '2018-07-01'
  proposal.proposed_end_date_time = '2018-08-01'
  proposal.proposed_spending_limit_micros = 1_000_000_000
end

# Send request to Google Ads API (not shown).
Perl
my $may_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    billingSetup =>
      Google::Ads::GoogleAds::V16::Utils::ResourceNames::billing_setup(
      $customer_id, $billing_setup_id
      ),
    proposalType => CREATE,
    proposedName => "May budget",
    proposedStartDateTime => "2018-05-01",
    proposedEndDateTime => "2018-06-01",
    proposedSpendingLimitMicros => 1000000000
  });

my $june_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    billingSetup =>
      Google::Ads::GoogleAds::V16::Utils::ResourceNames::billing_setup(
      $customer_id, $billing_setup_id
      ),
    proposalType => CREATE,
    proposedName => "June budget",
    proposedStartDateTime => "2018-06-01",
    proposedEndDateTime => "2018-07-01",
    proposedSpendingLimitMicros => 5000000000
  });

my $july_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    billingSetup =>
      Google::Ads::GoogleAds::V16::Utils::ResourceNames::billing_setup(
      $customer_id, $billing_setup_id
      ),
    proposalType => CREATE,
    proposedName => "July budget",
    proposedStartDateTime => "2018-07-01",
    proposedEndDateTime => "2018-08-01",
    proposedSpendingLimitMicros => 1000000000
  });

# Send request to Google Ads API (not shown).

請注意每個提案都使用了 AccountBudgetProposalType.CREATE。這會建立三筆預算,而不是更新同一筆預算三次

終止帳戶預算

您可以在啟用時結束帳戶預算,並在廣告活動開始前或待核准時完全移除。

結束使用中的帳戶預算

無法移除使用中的帳戶預算。不過,您可以將結束時間設為目前時間。最簡單的做法是使用 AccountBudgetProposalType.END 傳送提案。

下列程式碼片段示範如何結束現有的帳戶預算。

Java
AccountBudgetProposal.newBuilder()
  .setProposalType(AccountBudgetProposalType.END)
  .setAccountBudget(accountBudget.getResourceName())
  .build();

// Send request to Google Ads API (not shown).
C#
AccountBudgetProposal proposal = new AccountBudgetProposal()
{
  ProposalType = AccountBudgetProposalType.End,
  AccountBudget = accountBudget.ResourceName
};

// Send request to Google Ads API (not shown).
PHP
$accountBudgetProposal = new AccountBudgetProposal([
  'proposal_type' => AccountBudgetProposalType::END,
  'account_budget' => $accountBudget->getResourceName()
])

// Send request to Google Ads API (not shown).
Python
account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposal = account_budget_proposal_operation.create
proposal.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').END
proposal.account_budget = account_budget

# Send request to Google Ads API (not shown).
Ruby
proposal = client.resource.account_budget_proposal
proposal.proposal_type = :END
proposal.account_budget = account_budget.resource_name

# Send request to Google Ads API (not shown).
Perl
my $account_budget_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    proposalType => END,
    accountBudget => $account_budget->{resourceName});

# Send request to Google Ads API (not shown).

這相當於將結束日期時間設為 TimeType.NOW,藉此設定更新帳戶預算。

於開始時間前移除已核准的帳戶預算

如果您提議將帳戶預算開始進行,可以傳送 AccountBudgetProposalType.REMOVE 提案類型,在開始時間之前完全移除帳戶預算。

下列程式碼片段說明如何移除現有的未來帳戶預算。

Java
AccountBudgetProposal.newBuilder()
  .setProposalType(AccountBudgetProposalType.REMOVE)
  .setAccountBudget(accountBudget.getResourceName())
  .build();

// Send request to Google Ads API (not shown).
C#
AccountBudgetProposal proposal = new AccountBudgetProposal()
{
  ProposalType = AccountBudgetProposalType.Remove,
  AccountBudget = accountBudget.ResourceName
};

// Send request to Google Ads API (not shown).
PHP
$accountBudgetProposal = new AccountBudgetProposal([
  'proposal_type' => AccountBudgetProposalType::REMOVE,
  'account_budget' => $accountBudget->getResourceName()
])

// Send request to Google Ads API (not shown).
Python
account_budget_proposal_operation = client.get_type('AccountBudgetProposalOperation')
proposal = account_budget_proposal_operation.create
proposal.proposal_type = client.get_type('AccountBudgetProposalTypeEnum').REMOVE
proposal.account_budget = account_budget

# Send request to Google Ads API (not shown).
Ruby
proposal = client.resource.account_budget_proposal
proposal.proposal_type = :REMOVE
proposal.account_budget = account_budget.resource_name

# Send request to Google Ads API (not shown).
Perl
my $account_budget_proposal =
  Google::Ads::GoogleAds::V16::Resources::AccountBudgetProposal->new({
    proposalType => REMOVE,
    accountBudget => $account_budget->{resourceName});

# Send request to Google Ads API (not shown).