بودجه کمپین را ایجاد کنید

دو نوع بودجه وجود دارد: بودجه متوسط ​​روزانه و بودجه کل کمپین. می‌توانید هر دو نوع را با استفاده از CampaignBudgetService ایجاد کنید.

ایجاد بودجه متوسط ​​روزانه

این میانگین مبلغی است که مایلید روزانه برای این کمپین هزینه کنید. می‌توانید با استفاده از amount_micros از CampaignBudget ، میانگین بودجه روزانه را تعیین کنید. period بودجه به طور پیش‌فرض روی DAILY تنظیم شده است.

مثال زیر یک بودجه متوسط ​​روزانه جدید برای یک کمپین ایجاد می‌کند.

جاوا

private static String addCampaignBudget(GoogleAdsClient googleAdsClient, long customerId) {
  CampaignBudget budget =
      CampaignBudget.newBuilder()
          .setName("Interplanetary Cruise Budget #" + getPrintableDateTime())
          .setDeliveryMethod(BudgetDeliveryMethod.STANDARD)
          .setAmountMicros(500_000)
          .build();

  CampaignBudgetOperation op = CampaignBudgetOperation.newBuilder().setCreate(budget).build();

  try (CampaignBudgetServiceClient campaignBudgetServiceClient =
      googleAdsClient.getLatestVersion().createCampaignBudgetServiceClient()) {
    MutateCampaignBudgetsResponse response =
        campaignBudgetServiceClient.mutateCampaignBudgets(
            Long.toString(customerId), ImmutableList.of(op));
    String budgetResourceName = response.getResults(0).getResourceName();
    System.out.printf("Added budget: %s%n", budgetResourceName);
    return budgetResourceName;
  }
}
      

سی شارپ

private static string CreateBudget(GoogleAdsClient client, long customerId)
{
    // Get the BudgetService.
    CampaignBudgetServiceClient budgetService = client.GetService(
        Services.V23.CampaignBudgetService);

    // Create the campaign budget.
    CampaignBudget budget = new CampaignBudget()
    {
        Name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(),
        DeliveryMethod = BudgetDeliveryMethod.Standard,
        AmountMicros = 500000
    };

    // Create the operation.
    CampaignBudgetOperation budgetOperation = new CampaignBudgetOperation()
    {
        Create = budget
    };

    // Create the campaign budget.
    MutateCampaignBudgetsResponse response = budgetService.MutateCampaignBudgets(
        customerId.ToString(), new CampaignBudgetOperation[] { budgetOperation });
    return response.Results[0].ResourceName;
}
      

پی اچ پی

private static function addCampaignBudget(GoogleAdsClient $googleAdsClient, int $customerId)
{
    // Creates a campaign budget.
    $budget = new CampaignBudget([
        'name' => 'Interplanetary Cruise Budget #' . Helper::getPrintableDatetime(),
        'delivery_method' => BudgetDeliveryMethod::STANDARD,
        'amount_micros' => 500000
    ]);

    // Creates a campaign budget operation.
    $campaignBudgetOperation = new CampaignBudgetOperation();
    $campaignBudgetOperation->setCreate($budget);

    // Issues a mutate request.
    $campaignBudgetServiceClient = $googleAdsClient->getCampaignBudgetServiceClient();
    $response = $campaignBudgetServiceClient->mutateCampaignBudgets(
        MutateCampaignBudgetsRequest::build($customerId, [$campaignBudgetOperation])
    );

    /** @var CampaignBudget $addedBudget */
    $addedBudget = $response->getResults()[0];
    printf("Added budget named '%s'%s", $addedBudget->getResourceName(), PHP_EOL);

    return $addedBudget->getResourceName();
}
      

پایتون

# Create a budget, which can be shared by multiple campaigns.
campaign_budget_operation: CampaignBudgetOperation = client.get_type(
    "CampaignBudgetOperation"
)
campaign_budget: CampaignBudget = campaign_budget_operation.create
campaign_budget.name = f"Interplanetary Budget {uuid.uuid4()}"
campaign_budget.delivery_method = (
    client.enums.BudgetDeliveryMethodEnum.STANDARD
)
campaign_budget.amount_micros = 500000

# Add budget.
campaign_budget_response: MutateCampaignBudgetsResponse
try:
    budget_operations: List[CampaignBudgetOperation] = [
        campaign_budget_operation
    ]
    campaign_budget_response = (
        campaign_budget_service.mutate_campaign_budgets(
            customer_id=customer_id,
            operations=budget_operations,
        )
    )
except GoogleAdsException as ex:
    handle_googleads_exception(ex)
      

روبی

# Create a budget, which can be shared by multiple campaigns.
campaign_budget = client.resource.campaign_budget do |cb|
  cb.name = "Interplanetary Budget #{(Time.new.to_f * 1000).to_i}"
  cb.delivery_method = :STANDARD
  cb.amount_micros = 500000
end

operation = client.operation.create_resource.campaign_budget(campaign_budget)

# Add budget.
return_budget = client.service.campaign_budget.mutate_campaign_budgets(
  customer_id: customer_id,
  operations: [operation],
)
      

پرل

# Create a campaign budget, which can be shared by multiple campaigns.
my $campaign_budget =
  Google::Ads::GoogleAds::V23::Resources::CampaignBudget->new({
    name           => "Interplanetary budget #" . uniqid(),
    deliveryMethod => STANDARD,
    amountMicros   => 500000
  });

# Create a campaign budget operation.
my $campaign_budget_operation =
  Google::Ads::GoogleAds::V23::Services::CampaignBudgetService::CampaignBudgetOperation
  ->new({create => $campaign_budget});

# Add the campaign budget.
my $campaign_budgets_response = $api_client->CampaignBudgetService()->mutate({
    customerId => $customer_id,
    operations => [$campaign_budget_operation]});
      

حلقه زدن

بودجه کل کمپین را ایجاد کنید

این کل مبلغی است که مایلید در کل مدت زمان کمپین هزینه کنید. برای ایجاد بودجه کل کمپین، period بودجه را روی CUSTOM_PERIOD تنظیم کنید و total_amount_micros تنظیم کنید. بودجه کل کمپین را نمی‌توان بین کمپین‌ها به اشتراک گذاشت، بنابراین هنگام ایجاد بودجه با period CUSTOM_PERIOD ، باید explicitly_shared را روی false تنظیم کنید.

هنگام کدنویسی، فیلدها مانند میانگین بودجه روزانه هستند، به جز period و total_amount_micros .

توصیه‌های بودجه کمپین

API گوگل ادز انواع مختلفی از توصیه‌ها را برای کمک به شما در بهینه‌سازی بودجه کمپین‌هایتان ارائه می‌دهد:

  • CAMPAIGN_BUDGET مبلغ بودجه جدیدی را برای کمپین‌های با بودجه محدود پیشنهاد می‌دهد.

  • MOVE_UNUSED_BUDGET فرصت‌هایی را برای تخصیص مجدد بودجه اضافی از یک کمپین به کمپین دیگری که بودجه محدودی دارد، برجسته می‌کند.

  • MARGINAL_ROI_CAMPAIGN_BUDGET مبلغ بودجه جدیدی را برای کمپین‌هایی پیشنهاد می‌دهد که پیش‌بینی می‌شود ROI آنها با تنظیم بودجه افزایش یابد.

  • FORECASTING_CAMPAIGN_BUDGET مبلغ بودجه جدیدی را برای کمپین‌هایی که انتظار می‌رود در آینده با محدودیت بودجه مواجه شوند، پیشنهاد می‌دهد.

برای انواع توصیه‌های بیشتر و راهنمایی در مورد کار با توصیه‌ها در API گوگل ادز، به راهنمای امتیاز بهینه‌سازی و توصیه‌ها مراجعه کنید.