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

شما می توانید بودجه ای را به یک کمپین اختصاص دهید، بودجه را از یک کمپین جدا کنید، یا کمپین هایی را که به یک بودجه خاص اختصاص داده شده اند بازیابی کنید.

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

پس از اینکه یک CampaignBudget با CampaignBudgetService ایجاد کردید یا یک مورد موجود را شناسایی کردید ، باید از مقدار فیلد resource_name آن در تماس بعدی با CampaignService استفاده کنید. اگر عملیات ایجاد بودجه با موفقیت انجام شود، اما تخصیص کمپین با شکست مواجه شود، شما یک بودجه یتیم خواهید داشت (بودجه ای که با هیچ کمپینی مرتبط نیست). توصیه می کنیم از چنین بودجه هایی استفاده مجدد یا حذف کنید .

کمپین جدید

برای یک کمپین جدید، در CampaignOperation.create ، فیلد campaign_budget شی Campaign را روی نام منبع بودجه تنظیم کنید، همانطور که در مثال کد زیر نشان داده شده است.

جاوا

// Creates the campaign.
Campaign campaign =
    Campaign.newBuilder()
        .setName("Interplanetary Cruise #" + getPrintableDateTime())
        .setAdvertisingChannelType(AdvertisingChannelType.SEARCH)
        // Recommendation: Set the campaign to PAUSED when creating it to prevent
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve
        .setStatus(CampaignStatus.PAUSED)
        // Sets the bidding strategy and budget.
        .setManualCpc(ManualCpc.newBuilder().build())
        .setCampaignBudget(budgetResourceName)
        // Adds the networkSettings configured above.
        .setNetworkSettings(networkSettings)
        // Declares whether this campaign serves political ads targeting the EU.
        .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING)
        // Optional: Sets the start & end dates.
        .setStartDate(new DateTime().plusDays(1).toString("yyyyMMdd"))
        .setEndDate(new DateTime().plusDays(30).toString("yyyyMMdd"))
        .build();
      

سی شارپ

// Create the campaign.
Campaign campaign = new Campaign()
{
    Name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(),
    AdvertisingChannelType = AdvertisingChannelType.Search,

    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve
    Status = CampaignStatus.Paused,

    // Set the bidding strategy and budget.
    ManualCpc = new ManualCpc(),
    CampaignBudget = budget,

    // Set the campaign network options.
    NetworkSettings = new NetworkSettings
    {
        TargetGoogleSearch = true,
        TargetSearchNetwork = true,
        // Enable Display Expansion on Search campaigns. See
        // https://support.google.com/google-ads/answer/7193800 to learn more.
        TargetContentNetwork = true,
        TargetPartnerSearchNetwork = false
    },

    // Declare whether or not this campaign contains political ads targeting the EU.
    ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising,

    // Optional: Set the start date.
    StartDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"),

    // Optional: Set the end date.
    EndDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd"),
};
      

PHP

$campaign = new Campaign([
    'name' => 'Interplanetary Cruise #' . Helper::getPrintableDatetime(),
    'advertising_channel_type' => AdvertisingChannelType::SEARCH,
    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve.
    'status' => CampaignStatus::PAUSED,
    // Sets the bidding strategy and budget.
    'manual_cpc' => new ManualCpc(),
    'campaign_budget' => $budgetResourceName,
    // Adds the network settings configured above.
    'network_settings' => $networkSettings,
    // Declare whether or not this campaign serves political ads targeting the EU.
    'contains_eu_political_advertising' =>
        EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
    // Optional: Sets the start and end dates.
    'start_date' => date('Ymd', strtotime('+1 day')),
    'end_date' => date('Ymd', strtotime('+1 month'))
]);