يمكنك تعيين ميزانية لحملة أو إلغاء ربط ميزانية بحملة أو استرداد الحملات التي تم تعيينها لميزانية معيّنة.
تحديد ميزانية لإحدى الحملات
بعد إنشاء CampaignBudget باستخدام CampaignBudgetService أو تحديد عنصر حالي، يجب استخدام قيمة الحقل resource_name في طلب لاحق إلى CampaignService. في حال نجحت عملية إنشاء الميزانية، ولكن تعذّر ربطها بالحملة، ستصبح لديك ميزانية غير مرتبطة (أي ميزانية غير مرتبطة بأي حملة). ننصحك إما بإعادة استخدام هذه الميزانيات أو إزالتها.
حملة جديدة
بالنسبة إلى حملة جديدة، في
CampaignOperation.create،
اضبط حقل
campaign_budget
الكائن
Campaign
على اسم مرجع الميزانية، كما هو موضّح في مثال الرمز البرمجي أدناه.
Java
// 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();
#C
// 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')) ]);