캠페인에 예산을 할당하거나, 캠페인에서 예산을 연결 해제하거나, 특정 예산에 할당된 캠페인을 검색할 수 있습니다.
캠페인에 예산 할당
CampaignBudgetService
를 사용하여 CampaignBudget
를 만들거나 기존 CampaignBudget
를 식별한 후에는 후속 CampaignService
호출에서 CampaignBudget
의 resource_name
필드 값을 사용해야 합니다. 예산 생성 작업은 성공했지만 캠페인 할당은 실패하면 고아 예산 (캠페인과 연결되지 않은 예산)이 생성됩니다. 이러한 예산은 재사용하거나 삭제하는 것이 좋습니다.
새 캠페인
새 캠페인의 경우 아래 코드 예와 같이 CampaignOperation.create
에서 Campaign
객체의 campaign_budget
필드를 예산 리소스 이름으로 설정합니다.
자바
// 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) // 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 }, // 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, // Optional: Sets the start and end dates. 'start_date' => date('Ymd', strtotime('+1 day')), 'end_date' => date('Ymd', strtotime('+1 month')) ]);
Python
# Create campaign. campaign_operation = client.get_type("CampaignOperation") campaign = campaign_operation.create campaign.name = f"Interplanetary Cruise {uuid.uuid4()}" campaign.advertising_channel_type = ( client.enums.AdvertisingChannelTypeEnum.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. campaign.status = client.enums.CampaignStatusEnum.PAUSED # Set the bidding strategy and budget. campaign.manual_cpc.enhanced_cpc_enabled = True campaign.campaign_budget = campaign_budget_response.results[0].resource_name # Set the campaign network options. campaign.network_settings.target_google_search = True campaign.network_settings.target_search_network = True campaign.network_settings.target_partner_search_network = False # Enable Display Expansion on Search campaigns. For more details see: # https://support.google.com/google-ads/answer/7193800 campaign.network_settings.target_content_network = True
Ruby
# Create campaign. campaign = client.resource.campaign do |c| c.name = "Interplanetary Cruise #{(Time.new.to_f * 1000).to_i}" c.advertising_channel_type = :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. c.status = :PAUSED # Set the bidding strategy and budget. c.manual_cpc = client.resource.manual_cpc c.campaign_budget = return_budget.results.first.resource_name # Set the campaign network options. c.network_settings = client.resource.network_settings do |ns| ns.target_google_search = true ns.target_search_network = true # Enable Display Expansion on Search campaigns. See # https://support.google.com/google-ads/answer/7193800 to learn more. ns.target_content_network = true ns.target_partner_search_network = false end # Optional: Set the start date. c.start_date = DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d') # Optional: Set the end date. c.end_date = DateTime.parse((Date.today.next_year).to_s).strftime('%Y%m%d') end
Perl
# Create a campaign. my $campaign = Google::Ads::GoogleAds::V18::Resources::Campaign->new({ name => "Interplanetary Cruise #" . uniqid(), advertisingChannelType => SEARCH, # Recommendation: Set the campaign to PAUSED when creating it to stop # the ads from immediately serving. Set to ENABLED once you've added # targeting and the ads are ready to serve. status => PAUSED, # Set the bidding strategy and budget. manualCpc => Google::Ads::GoogleAds::V18::Common::ManualCpc->new( {enhancedCpcEnabled => "true"} ), campaignBudget => $campaign_budgets_response->{results}[0]{resourceName}, # Set the campaign network options. networkSettings => Google::Ads::GoogleAds::V18::Resources::NetworkSettings->new({ 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" } ), # Optional: Set the start date. The campaign starts tomorrow. startDate => strftime("%Y%m%d", localtime(time + 60 * 60 * 24)), # Optional: Set the end date. The campaign runs for 30 days. endDate => strftime("%Y%m%d", localtime(time + 60 * 60 * 24 * 30)), });
기존 캠페인
기존 캠페인의 예산을 교체하려면 CampaignOperation.update
에서 Campaign
객체의 campaign_budget
필드를 설정하려는 다른 캠페인 필드와 함께 기존 예산의 리소스 이름으로 설정합니다. 캠페인은 한 번에 하나의 예산에만 연결할 수 있으므로 캠페인에 할당된 기존 예산이 campaign_budget
필드에 지정된 예산으로 대체됩니다.
캠페인에서 예산 연결 해제하기
캠페인은 항상 예산과 연결되어야 합니다. 캠페인과 연결된 예산을 변경하여 캠페인에서 예산을 삭제하고 다른 예산으로 대체할 수 있습니다. 특정 예산을 사용하는 캠페인을 식별하려면 다음 섹션으로 진행하세요.
예산에 할당된 캠페인 검색
동일한 예산을 사용하는 캠페인 목록을 가져오면 예산 활용의 균형을 유지하는 데 도움이 될 수 있습니다. 다음 GAQL 쿼리는 지정된 예산 ID의 모든 캠페인을 반환합니다.
SELECT campaign.id FROM campaign WHERE campaign_budget.id = campaign_budget_id