포트폴리오 입찰 전략 은 여러 캠페인 간에 공유할 수 있는 목표 중심의 자동화된 입찰 전략인 반면 일반 입찰 전략 은 공유되지 않으며 단일 캠페인에서만 사용할 수 있습니다. API는 두 가지 유형의 전략을 모두 만들 수 있도록 지원합니다. 포트폴리오 입찰 전략은 계정에서 독립형 객체로 생성되는 반면 일반 전략은 캠페인에서 적절한 필드를 설정하여 관리됩니다.
포트폴리오 입찰 전략
캠페인에서 포트폴리오 입찰 전략 을 사용하려면 다음 두 가지 옵션이 있습니다.
- 기존
BiddingStrategy를 사용합니다. MutateBiddingStrategies를 사용하여name및scheme필드가 설정된 새 필드를 만듭니다. 예를 들어TARGET_SPEND입찰 전략의 경우target_spendTargetSpend유형의 새 객체로 필드를 설정합니다.
BiddingStrategy를 선택한 후 캠페인의
bidding_strategy
필드를 resource_name으로 설정하여 캠페인이 이를 사용하도록 구성합니다.
다음 예에서는 새 캠페인을 위한 새 포트폴리오 TARGET_SPEND 입찰 전략을 만드는 방법을 보여줍니다.
자바
private String createBiddingStrategy(GoogleAdsClient googleAdsClient, long customerId) { try (BiddingStrategyServiceClient biddingStrategyServiceClient = googleAdsClient.getLatestVersion().createBiddingStrategyServiceClient()) { // Creates a portfolio bidding strategy. TargetSpend targetSpend = TargetSpend.newBuilder().setCpcBidCeilingMicros(2_000_000L).build(); BiddingStrategy portfolioBiddingStrategy = BiddingStrategy.newBuilder() .setName("Maximize Clicks #" + getPrintableDateTime()) .setTargetSpend(targetSpend) .build(); // Constructs an operation that will create a portfolio bidding strategy. BiddingStrategyOperation operation = BiddingStrategyOperation.newBuilder().setCreate(portfolioBiddingStrategy).build(); // Sends the operation in a mutate request. MutateBiddingStrategiesResponse response = biddingStrategyServiceClient.mutateBiddingStrategies( Long.toString(customerId), Lists.newArrayList(operation)); MutateBiddingStrategyResult mutateBiddingStrategyResult = response.getResults(0); // Prints the resource name of the created object. System.out.printf( "Created portfolio bidding strategy with resource name: '%s'.%n", mutateBiddingStrategyResult.getResourceName()); return mutateBiddingStrategyResult.getResourceName(); } }
C#
private string CreatePortfolioBiddingStrategy(GoogleAdsClient client, long customerId, string name, long bidCeiling) { // Get the BiddingStrategyService. BiddingStrategyServiceClient biddingStrategyService = client.GetService( Services.V25.BiddingStrategyService); // Create a portfolio bidding strategy. BiddingStrategy biddingStrategy = new BiddingStrategy() { Name = name, TargetSpend = new TargetSpend() { CpcBidCeilingMicros = bidCeiling, } }; // Create operation. BiddingStrategyOperation biddingOperation = new BiddingStrategyOperation() { Create = biddingStrategy }; // Create the portfolio bidding strategy. MutateBiddingStrategiesResponse biddingResponse = biddingStrategyService.MutateBiddingStrategies( customerId.ToString(), new BiddingStrategyOperation[] { biddingOperation }); return biddingResponse.Results[0].ResourceName; }
PHP
private static function createBiddingStrategy(GoogleAdsClient $googleAdsClient, int $customerId) { // Creates a portfolio bidding strategy. $portfolioBiddingStrategy = new BiddingStrategy( [ 'name' => 'Maximize Clicks #' . Helper::getPrintableDatetime(), 'target_spend' => new TargetSpend( [ 'cpc_bid_ceiling_micros' => 2000000 ] ) ] ); // Constructs an operation that will create a portfolio bidding strategy. $biddingStrategyOperation = new BiddingStrategyOperation(); $biddingStrategyOperation->setCreate($portfolioBiddingStrategy); // Issues a mutate request to create the bidding strategy. $biddingStrategyServiceClient = $googleAdsClient->getBiddingStrategyServiceClient(); $response = $biddingStrategyServiceClient->mutateBiddingStrategies( MutateBiddingStrategiesRequest::build($customerId, [$biddingStrategyOperation]) ); /** * @var BiddingStrategy $addedBiddingStrategy */ $addedBiddingStrategy = $response->getResults()[0]; // Prints out the resource name of the created bidding strategy. printf( "Created portfolio bidding strategy with resource name: '%s'.%s", $addedBiddingStrategy->getResourceName(), PHP_EOL ); return $addedBiddingStrategy->getResourceName(); }
Python
# Create a portfolio bidding strategy. bidding_strategy_operation: BiddingStrategyOperation = client.get_type( "BiddingStrategyOperation" ) bidding_strategy: BiddingStrategy = bidding_strategy_operation.create bidding_strategy.name = f"Enhanced CPC {uuid.uuid4()}" target_spend: TargetSpend = bidding_strategy.target_spend target_spend.cpc_bid_ceiling_micros = 2000000 # Add portfolio bidding strategy. try: bidding_strategy_response: MutateBiddingStrategiesResponse = ( bidding_strategy_service.mutate_bidding_strategies( customer_id=customer_id, operations=[bidding_strategy_operation] ) ) bidding_strategy_id: str = bidding_strategy_response.results[ 0 ].resource_name print(f'Created portfolio bidding strategy "{bidding_strategy_id}".') except GoogleAdsException as ex: handle_googleads_exception(ex)
Ruby
# Create a portfolio bidding strategy. bidding_strategy = client.resource.bidding_strategy do |bs| bs.name = "Enhanced CPC ##{(Time.new.to_f * 1000).to_i}" bs.target_spend = client.resource.target_spend do |ts| ts.cpc_bid_ceiling_micros = 2_000_000 end end operation = client.operation.create_resource.bidding_strategy(bidding_strategy) response = client.service.bidding_strategy.mutate_bidding_strategies( customer_id: customer_id, operations: [operation], ) bidding_id = response.results.first.resource_name puts "Portfolio bidding strategy #{bidding_id} was created"
Perl
sub create_bidding_strategy { my ($api_client, $customer_id) = @_; # Create a portfolio bidding strategy. my $portfolio_bidding_strategy = Google::Ads::GoogleAds::V25::Resources::BiddingStrategy->new({ name => "Maximize Clicks #" . uniqid(), targetSpend => Google::Ads::GoogleAds::V25::Common::TargetSpend->new({ cpcBidCeilingMicros => 2000000 } ), }); # Create a bidding strategy operation. my $bidding_strategy_operation = Google::Ads::GoogleAds::V25::Services::BiddingStrategyService::BiddingStrategyOperation ->new({ create => $portfolio_bidding_strategy }); # Add the bidding strategy. my $bidding_strategies_response = $api_client->BiddingStrategyService()->mutate({ customerId => $customer_id, operations => [$bidding_strategy_operation]}); my $bidding_strategy_resource_name = $bidding_strategies_response->{results}[0]{resourceName}; printf "Created portfolio bidding strategy with resource name: '%s'.\n", $bidding_strategy_resource_name; return $bidding_strategy_resource_name; }
curl
자바
Campaign campaign = Campaign.newBuilder() .setName("Interplanetary Cruise #" + getPrintableDateTime()) .setStatus(CampaignStatus.PAUSED) .setCampaignBudget(campaignBudgetResourceName) .setBiddingStrategy(biddingStrategyResourceName) .setAdvertisingChannelType(AdvertisingChannelType.SEARCH) .setNetworkSettings(networkSettings) // Declares whether this campaign serves political ads targeting the EU. .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING) .build();
C#
// Create the campaign. Campaign campaign = new Campaign() { Name = name, 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 campaign budget. CampaignBudget = campaignBudgetResourceName, // Set bidding strategy (required). BiddingStrategy = biddingStrategyResourceName, // Set the campaign network options. NetworkSettings = new NetworkSettings() { TargetGoogleSearch = true, TargetSearchNetwork = true, TargetContentNetwork = true, TargetPartnerSearchNetwork = false }, // Declare whether or not this campaign contains political ads targeting the EU. ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising, };
PHP
// Creates a Search campaign. $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, // Configures the campaign network options. 'network_settings' => new NetworkSettings( [ 'target_google_search' => true, 'target_search_network' => true, 'target_content_network' => true, ] ), // Sets the bidding strategy and budget. 'bidding_strategy' => $biddingStrategyResourceName, 'campaign_budget' => $campaignBudgetResourceName, // Declare whether or not this campaign serves political ads targeting the EU. 'contains_eu_political_advertising' => EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING ] );
Python
# Create campaign. campaign_operation: CampaignOperation = client.get_type("CampaignOperation") campaign: 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.bidding_strategy = bidding_strategy_id campaign.manual_cpc.enhanced_cpc_enabled = True campaign.campaign_budget = campaign_budget_id # Set the campaign network options. campaign.network_settings.target_google_search = True campaign.network_settings.target_search_network = True campaign.network_settings.target_content_network = False campaign.network_settings.target_partner_search_network = False campaign.contains_eu_political_advertising = ( client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING )
Ruby
# Create campaigns. campaigns = 2.times.map do |i| client.resource.campaign do |c| c.name = "Interplanetary Cruise ##{(Time.new.to_f * 1000).to_i + i}" c.status = :PAUSED c.bidding_strategy = bidding_id c.campaign_budget = budget_id c.advertising_channel_type = :SEARCH c.network_settings = client.resource.network_settings do |ns| ns.target_google_search = true ns.target_search_network = true ns.target_content_network = false ns.target_partner_search_network = false c.contains_eu_political_advertising = :DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING end end end
Perl
# Create a search campaign. my $campaign = Google::Ads::GoogleAds::V25::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, # Configures the campaign network options. networkSettings => Google::Ads::GoogleAds::V25::Resources::NetworkSettings->new({ targetGoogleSearch => "true", targetSearchNetwork => "true", targetContentNetwork => "true" } ), # Set the bidding strategy and budget. biddingStrategy => $bidding_strategy_resource_name, campaignBudget => $campaign_budget_resource_name, # Declare whether or not this campaign serves political ads targeting the EU. # Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING. containsEuPoliticalAdvertising => DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING });
curl
공유 예산에 연결
기존 포트폴리오 입찰 전략을 연결하여 공유 예산에 사용할 수 있습니다. 두 항목이 연결되면 공유 예산은 항상 입찰 전략에 포함된 캠페인과 연결됩니다.
포트폴리오 입찰 전략과 기존 공유 예산만 연결할 수 있습니다. 둘 중 하나를 만들고 즉시 다른 하나와 연결할 수는 없습니다.
BiddingStrategy를
CampaignBudget과 연결하려면 두
항목을 업데이트하는
MutateOperation을 전송하여 입찰 전략의
aligned_campaign_budget_id
필드를 공유 예산의 ID로 설정하고 캠페인 예산의
aligned_bidding_strategy_id
필드를 포트폴리오 입찰 전략의 ID로 설정합니다.
일반 입찰 전략
캠페인에서 일반 입찰 전략을 사용하려면 다음과 같이 캠페인을 설정합니다.
- 유니언 필드를 설정하여 사용할 입찰 계획을 삽입합니다.
campaign_bidding_strategy따라서TARGET_CPA입찰 전략의 경우 새 입찰 계획 객체 유형TargetCpa으로 필드target_cpa를 설정합니다. - not 필드를 설정하지
bidding_strategy마세요.
이 예에서는 새 캠페인을 만들 때 일반
MAXIMIZE_CONVERSION_VALUE
입찰 전략을 설정하는 방법을 보여줍니다.
자바
/** Creates a MutateOperation that creates a new Performance Max campaign. */ private MutateOperation createPerformanceMaxCampaignOperation( long customerId, boolean brandGuidelinesEnabled) { TextGuidelines textGuidelines = TextGuidelines.newBuilder() // Specifies a list of terms that should not be used in any auto-generated // text assets. .addAllTermExclusions(ImmutableList.of("cheap", "free")) // Specifies freeform messaging restriction prompts that will apply to all // auto-generated text assets. .addMessagingRestrictions( MessagingRestriction.newBuilder() .setRestrictionText("Don't mention competitor names") .setRestrictionType( MessagingRestrictionType.RESTRICTION_BASED_EXCLUSION) .build()) .build(); Campaign performanceMaxCampaign = Campaign.newBuilder() .setName("Performance Max campaign #" + getPrintableDateTime()) // Sets the campaign status as PAUSED. The campaign is the only entity in // the mutate request that should have its status set. .setStatus(CampaignStatus.PAUSED) // All Performance Max campaigns have an advertising_channel_type of // PERFORMANCE_MAX. The advertising_channel_sub_type should not be set. .setAdvertisingChannelType(AdvertisingChannelType.PERFORMANCE_MAX) // Bidding strategy must be set directly on the campaign. // Setting a portfolio bidding strategy by resource name is not supported. // Max Conversion and Maximize Conversion Value are the only strategies // supported for Performance Max campaigns. // An optional ROAS (Return on Advertising Spend) can be set for // maximize_conversion_value. The ROAS value must be specified as a ratio in // the API. It is calculated by dividing "total value" by "total spend". // For more information on Maximize Conversion Value, see the support // article: http://support.google.com/google-ads/answer/7684216. // A targetRoas of 3.5 corresponds to a 350% return on ad spend. .setMaximizeConversionValue( MaximizeConversionValue.newBuilder().setTargetRoas(3.5).build()) // Sets if the campaign is enabled for brand guidelines. For more information on brand // guidelines, see https://support.google.com/google-ads/answer/14934472. .setBrandGuidelinesEnabled(brandGuidelinesEnabled) // Sets the text guidelines. .setTextGuidelines(textGuidelines) // Assigns the resource name with a temporary ID. .setResourceName( ResourceNames.campaign(customerId, PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)) // Sets the budget using the given budget resource name. .setCampaignBudget(ResourceNames.campaignBudget(customerId, BUDGET_TEMPORARY_ID)) // Declares whether this campaign serves political ads targeting the EU. .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING) // Optional fields. .setStartDateTime(new DateTime().plusDays(1).toString("yyyy-MM-dd 00:00:00")) .setEndDateTime(new DateTime().plusDays(365).toString("yyyy-MM-dd 23:59:59")) // Configures the optional opt-in/out status for asset automation settings. .addAllAssetAutomationSettings(ImmutableList.of( AssetAutomationSetting.newBuilder() .setAssetAutomationType(AssetAutomationType.GENERATE_IMAGE_EXTRACTION) .setAssetAutomationStatus(AssetAutomationStatus.OPTED_IN).build(), AssetAutomationSetting.newBuilder() .setAssetAutomationType( AssetAutomationType.FINAL_URL_EXPANSION_TEXT_ASSET_AUTOMATION) .setAssetAutomationStatus(AssetAutomationStatus.OPTED_IN).build(), AssetAutomationSetting.newBuilder() .setAssetAutomationType(AssetAutomationType.TEXT_ASSET_AUTOMATION) .setAssetAutomationStatus(AssetAutomationStatus.OPTED_IN).build(), AssetAutomationSetting.newBuilder() .setAssetAutomationType(AssetAutomationType.GENERATE_ENHANCED_YOUTUBE_VIDEOS) .setAssetAutomationStatus(AssetAutomationStatus.OPTED_IN).build(), AssetAutomationSetting.newBuilder() .setAssetAutomationType(AssetAutomationType.GENERATE_IMAGE_ENHANCEMENT) .setAssetAutomationStatus(AssetAutomationStatus.OPTED_IN).build())) .build(); return MutateOperation.newBuilder() .setCampaignOperation( CampaignOperation.newBuilder().setCreate(performanceMaxCampaign).build()) .build(); }
C#
/// Creates a MutateOperation that creates a new Performance Max campaign. /// <param name="campaignResourceName">The campaign resource name.</param> /// <param name="campaignBudgetResourceName">The campaign budget resource name.</param> /// <param name="brandGuidelinesEnabled">Whether or not to enable brand guidelines.</param> /// <returns>A MutateOperations that will create this new campaign.</returns> private MutateOperation CreatePerformanceMaxCampaignOperation( string campaignResourceName, string campaignBudgetResourceName, bool brandGuidelinesEnabled) { Campaign.Types.TextGuidelines textGuidelines = new Campaign.Types.TextGuidelines(); textGuidelines.TermExclusions.AddRange(["cheap", "free"]); textGuidelines.MessagingRestrictions.Add( new Campaign.Types.MessagingRestriction() { RestrictionText = "Don't mention competitor names", RestrictionType = MessagingRestrictionType.RestrictionBasedExclusion } ); Campaign campaign = new Campaign() { Name = "Performance Max campaign #" + ExampleUtilities.GetRandomString(), // Set the campaign status as PAUSED. The campaign is the only entity in // the mutate request that should have its status set. Status = CampaignStatus.Paused, // All Performance Max campaigns have an AdvertisingChannelType of // PerformanceMax. The AdvertisingChannelSubType should not be set. AdvertisingChannelType = AdvertisingChannelType.PerformanceMax, // Bidding strategy must be set directly on the campaign. Setting a // portfolio bidding strategy by resource name is not supported. Max // Conversion and Maximize Conversion Value are the only strategies // supported for Performance Max campaigns. BiddingStrategyType is // read-only and cannot be set by the API. An optional ROAS (Return on // Advertising Spend) can be set to enable the MaximizeConversionValue // bidding strategy. The ROAS value must be specified as a ratio in the API. // It is calculated by dividing "total value" by "total spend". // // For more information on Maximize Conversion Value, see the support // article: // http://support.google.com/google-ads/answer/7684216. // // A target_roas of 3.5 corresponds to a 350% return on ad spend. MaximizeConversionValue = new MaximizeConversionValue() { TargetRoas = 3.5 }, // Use the temporary resource name created earlier ResourceName = campaignResourceName, // Set the budget using the given budget resource name. CampaignBudget = campaignBudgetResourceName, // Set if the campaign is enabled for brand guidelines. For more information // on brand guidelines, see https://support.google.com/google-ads/answer/14934472. BrandGuidelinesEnabled = brandGuidelinesEnabled, // Declare whether or not this campaign contains political ads targeting the EU. ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising, TextGuidelines = textGuidelines, // Optional fields StartDateTime = DateTime.Now.AddDays(1).ToString("yyyyMMdd 00:00:00"), EndDateTime = DateTime.Now.AddDays(365).ToString("yyyyMMdd 23:59:59") }; campaign.AssetAutomationSettings.AddRange(new[]{ new Campaign.Types.AssetAutomationSetting { AssetAutomationType = AssetAutomationType.GenerateImageExtraction, AssetAutomationStatus = AssetAutomationStatus.OptedIn }, new Campaign.Types.AssetAutomationSetting { AssetAutomationType = AssetAutomationType.FinalUrlExpansionTextAssetAutomation, AssetAutomationStatus = AssetAutomationStatus.OptedIn }, new Campaign.Types.AssetAutomationSetting { AssetAutomationType = AssetAutomationType.TextAssetAutomation, AssetAutomationStatus = AssetAutomationStatus.OptedIn }, new Campaign.Types.AssetAutomationSetting { AssetAutomationType = AssetAutomationType.GenerateEnhancedYoutubeVideos, AssetAutomationStatus = AssetAutomationStatus.OptedIn }, new Campaign.Types.AssetAutomationSetting { AssetAutomationType = AssetAutomationType.GenerateImageEnhancement, AssetAutomationStatus = AssetAutomationStatus.OptedIn }, }); MutateOperation operation = new MutateOperation() { CampaignOperation = new CampaignOperation() { Create = campaign } }; return operation; }
PHP
private static function createPerformanceMaxCampaignOperation( int $customerId, bool $brandGuidelinesEnabled ): MutateOperation { // Creates a mutate operation that creates a campaign operation. return new MutateOperation( [ 'campaign_operation' => new CampaignOperation( [ 'create' => new Campaign( [ 'name' => 'Performance Max campaign #' . Helper::getPrintableDatetime(), // Assigns the resource name with a temporary ID. 'resource_name' => ResourceNames::forCampaign( $customerId, self::PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID ), // Sets the budget using the given budget resource name. 'campaign_budget' => ResourceNames::forCampaignBudget( $customerId, self::BUDGET_TEMPORARY_ID ), // The campaign is the only entity in the mutate request that should have its // status set. // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. 'status' => CampaignStatus::PAUSED, // All Performance Max campaigns have an advertising_channel_type of // PERFORMANCE_MAX. The advertising_channel_sub_type should not be set. 'advertising_channel_type' => AdvertisingChannelType::PERFORMANCE_MAX, // Bidding strategy must be set directly on the campaign. // Setting a portfolio bidding strategy by resource name is not supported. // Max Conversion and Maximize Conversion Value are the only strategies // supported for Performance Max campaigns. // An optional ROAS (Return on Advertising Spend) can be set for // maximize_conversion_value. The ROAS value must be specified as a ratio in // the API. It is calculated by dividing "total value" by "total spend". // For more information on Maximize Conversion Value, see the support // article: http://support.google.com/google-ads/answer/7684216. // A target_roas of 3.5 corresponds to a 350% return on ad spend. 'maximize_conversion_value' => new MaximizeConversionValue( [ 'target_roas' => 3.5 ] ), 'asset_automation_settings' => [ new AssetAutomationSetting( [ 'asset_automation_type' => AssetAutomationType::TEXT_ASSET_AUTOMATION, 'asset_automation_status' => AssetAutomationStatus::OPTED_IN ] ), new AssetAutomationSetting( [ 'asset_automation_type' => AssetAutomationType::URL_EXPANSION, 'asset_automation_status' => AssetAutomationStatus::OPTED_IN ] ) ], // Sets if the campaign is enabled for brand guidelines. For more information // on brand guidelines, see // https://support.google.com/google-ads/answer/14934472. 'brand_guidelines_enabled' => $brandGuidelinesEnabled, // Declare whether or not this campaign serves political ads targeting the EU. 'contains_eu_political_advertising' => EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING, // Optional fields. 'start_date_time' => date('Y-m-d 00:00:00', strtotime('+1 day')), 'end_date_time' => date('Y-m-d 23:59:59', strtotime('+365 days')) ] ) ] ) ] ); }
Python
def create_performance_max_campaign_operation( client: GoogleAdsClient, customer_id: str, brand_guidelines_enabled: bool, ) -> MutateOperation: """Creates a MutateOperation that creates a new Performance Max campaign. A temporary ID will be assigned to this campaign so that it can be referenced by other objects being created in the same Mutate request. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. brand_guidelines_enabled: a boolean value indicating if the campaign is enabled for brand guidelines. Returns: a MutateOperation that creates a campaign. """ mutate_operation: MutateOperation = client.get_type("MutateOperation") campaign: Campaign = mutate_operation.campaign_operation.create campaign.name = f"Performance Max campaign #{uuid4()}" # Set the campaign status as PAUSED. The campaign is the only entity in # the mutate request that should have its status set. campaign.status = client.enums.CampaignStatusEnum.PAUSED # All Performance Max campaigns have an advertising_channel_type of # PERFORMANCE_MAX. The advertising_channel_sub_type should not be set. campaign.advertising_channel_type = ( client.enums.AdvertisingChannelTypeEnum.PERFORMANCE_MAX ) # Bidding strategy must be set directly on the campaign. # Setting a portfolio bidding strategy by resource name is not supported. # Max Conversion and Maximize Conversion Value are the only strategies # supported for Performance Max campaigns. # An optional ROAS (Return on Advertising Spend) can be set for # maximize_conversion_value. The ROAS value must be specified as a ratio in # the API. It is calculated by dividing "total value" by "total spend". # For more information on Maximize Conversion Value, see the support # article: http://support.google.com/google-ads/answer/7684216. # A target_roas of 3.5 corresponds to a 350% return on ad spend. campaign.bidding_strategy_type = ( client.enums.BiddingStrategyTypeEnum.MAXIMIZE_CONVERSION_VALUE ) campaign.maximize_conversion_value.target_roas = 3.5 # Set if the campaign is enabled for brand guidelines. For more information # on brand guidelines, see https://support.google.com/google-ads/answer/14934472. campaign.brand_guidelines_enabled = brand_guidelines_enabled # Assign the resource name with a temporary ID. campaign_service: CampaignServiceClient = client.get_service( "CampaignService" ) campaign.resource_name = campaign_service.campaign_path( customer_id, _PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID ) # Set the budget using the given budget resource name. campaign.campaign_budget = campaign_service.campaign_budget_path( customer_id, _BUDGET_TEMPORARY_ID ) # Declare whether or not this campaign serves political ads targeting the # EU. Valid values are: # CONTAINS_EU_POLITICAL_ADVERTISING # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING campaign.contains_eu_political_advertising = ( client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING ) # Optional fields campaign.start_date_time = (datetime.now() + timedelta(1)).strftime( "%Y%m%d 00:00:00" ) campaign.end_date_time = (datetime.now() + timedelta(365)).strftime( "%Y%m%d 23:59:59" ) campaign.text_guidelines.term_exclusions = ["cheap", "free"] messaging_restriction = campaign.MessagingRestriction() messaging_restriction.restriction_text = "Don't mention competitor names" messaging_restriction.restriction_type = ( client.enums.MessagingRestrictionTypeEnum.RESTRICTION_BASED_EXCLUSION ) campaign.text_guidelines.messaging_restrictions.append( messaging_restriction ) # Configures the optional opt-in/out status for asset automation settings. for asset_automation_type_enum in [ client.enums.AssetAutomationTypeEnum.GENERATE_IMAGE_EXTRACTION, client.enums.AssetAutomationTypeEnum.FINAL_URL_EXPANSION_TEXT_ASSET_AUTOMATION, client.enums.AssetAutomationTypeEnum.TEXT_ASSET_AUTOMATION, client.enums.AssetAutomationTypeEnum.GENERATE_ENHANCED_YOUTUBE_VIDEOS, client.enums.AssetAutomationTypeEnum.GENERATE_IMAGE_ENHANCEMENT, ]: asset_automattion_setting: Campaign.AssetAutomationSetting = ( client.get_type("Campaign").AssetAutomationSetting() ) asset_automattion_setting.asset_automation_type = ( asset_automation_type_enum ) asset_automattion_setting.asset_automation_status = ( client.enums.AssetAutomationStatusEnum.OPTED_IN ) campaign.asset_automation_settings.append(asset_automattion_setting) return mutate_operation
Ruby
# Creates a MutateOperation that creates a new Performance Max campaign. # # A temporary ID will be assigned to this campaign so that it can # be referenced by other objects being created in the same Mutate request. def create_performance_max_campaign_operation( client, customer_id, brand_guidelines_enabled) client.operation.mutate do |m| m.campaign_operation = client.operation.create_resource.campaign do |c| c.name = "Performance Max campaign #{SecureRandom.uuid}" # Set the campaign status as PAUSED. The campaign is the only entity in # the mutate request that should have its status set. c.status = :PAUSED # All Performance Max campaigns have an advertising_channel_type of # PERFORMANCE_MAX. The advertising_channel_sub_type should not be set. c.advertising_channel_type = :PERFORMANCE_MAX # Bidding strategy must be set directly on the campaign. # Setting a portfolio bidding strategy by resource name is not supported. # Max Conversion and Maximize Conversion Value are the only strategies # supported for Performance Max campaigns. # An optional ROAS (Return on Advertising Spend) can be set for # maximize_conversion_value. The ROAS value must be specified as a ratio in # the API. It is calculated by dividing "total value" by "total spend". # For more information on Maximize Conversion Value, see the support # article: http://support.google.com/google-ads/answer/7684216. # A target_roas of 3.5 corresponds to a 350% return on ad spend. c.bidding_strategy_type = :MAXIMIZE_CONVERSION_VALUE c.maximize_conversion_value = client.resource.maximize_conversion_value do |mcv| mcv.target_roas = 3.5 end # Configures the optional opt-in/out status for asset automation settings. c.asset_automation_settings << client.resource.asset_automation_setting do |aas| aas.asset_automation_type = :GENERATE_IMAGE_EXTRACTION aas.asset_automation_status = :OPTED_IN end c.asset_automation_settings << client.resource.asset_automation_setting do |aas| aas.asset_automation_type = :FINAL_URL_EXPANSION_TEXT_ASSET_AUTOMATION aas.asset_automation_status = :OPTED_IN end c.asset_automation_settings << client.resource.asset_automation_setting do |aas| aas.asset_automation_type = :TEXT_ASSET_AUTOMATION aas.asset_automation_status = :OPTED_IN end c.asset_automation_settings << client.resource.asset_automation_setting do |aas| aas.asset_automation_type = :GENERATE_ENHANCED_YOUTUBE_VIDEOS aas.asset_automation_status = :OPTED_IN end c.asset_automation_settings << client.resource.asset_automation_setting do |aas| aas.asset_automation_type = :GENERATE_IMAGE_ENHANCEMENT aas.asset_automation_status = :OPTED_IN end # Set if the campaign is enabled for brand guidelines. For more # information on brand guidelines, see # https://support.google.com/google-ads/answer/14934472. c.brand_guidelines_enabled = brand_guidelines_enabled # Assign the resource name with a temporary ID. c.resource_name = client.path.campaign(customer_id, PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID) # Set the budget using the given budget resource name. c.campaign_budget = client.path.campaign_budget(customer_id, BUDGET_TEMPORARY_ID) # Declare whether or not this campaign serves political ads targeting the EU. # Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING. c.contains_eu_political_advertising = :DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING # Optional fields c.start_date_time = DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d %H:%M:%S') c.end_date_time = DateTime.parse(Date.today.next_year.to_s).strftime('%Y%m%d %H:%M:%S') end end end
Perl
sub create_performance_max_campaign_operation { my ($customer_id, $brand_guidelines_enabled) = @_; # Configures the optional opt-in/out status for asset automation settings. # When we create the campaign object, we set campaign->{assetAutomationSettings} # equal to $asset_automation_settings. my $asset_automation_settings = []; my $asset_automation_types = [ GENERATE_IMAGE_EXTRACTION, FINAL_URL_EXPANSION_TEXT_ASSET_AUTOMATION, TEXT_ASSET_AUTOMATION, GENERATE_ENHANCED_YOUTUBE_VIDEOS, GENERATE_IMAGE_ENHANCEMENT ]; foreach my $asset_automation_type (@$asset_automation_types) { push @$asset_automation_settings, Google::Ads::GoogleAds::V25::Resources::AssetAutomationSetting->new({ assetAutomationStatus => OPTED_IN, assetAutomationType => $asset_automation_type }); } my $text_guidelines = Google::Ads::GoogleAds::V25::Resources::TextGuidelines->new({ termExclusions => ["cheap", "free"], messagingRestrictions => [ Google::Ads::GoogleAds::V25::Resources::MessagingRestriction->new({ restrictionText => "Don't mention competitor names", restrictionType => RESTRICTION_BASED_EXCLUSION })]}); # Create a mutate operation that creates a campaign operation. return Google::Ads::GoogleAds::V25::Services::GoogleAdsService::MutateOperation-> new({ campaignOperation => Google::Ads::GoogleAds::V25::Services::CampaignService::CampaignOperation ->new({ create => Google::Ads::GoogleAds::V25::Resources::Campaign->new({ # Assign the resource name with a temporary ID. resourceName => Google::Ads::GoogleAds::V25::Utils::ResourceNames::campaign( $customer_id, PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID ), name => "Performance Max campaign #" . uniqid(), # Set the budget using the given budget resource name. campaignBudget => Google::Ads::GoogleAds::V25::Utils::ResourceNames::campaign_budget( $customer_id, BUDGET_TEMPORARY_ID ), # Set the campaign status as PAUSED. The campaign is the only entity in # the mutate request that should have its status set. status => Google::Ads::GoogleAds::V25::Enums::CampaignStatusEnum::PAUSED, # All Performance Max campaigns have an advertisingChannelType of # PERFORMANCE_MAX. The advertisingChannelSubType should not be set. advertisingChannelType => PERFORMANCE_MAX, # Bidding strategy must be set directly on the campaign. # Setting a portfolio bidding strategy by resource name is not supported. # Max Conversion and Maximize Conversion Value are the only strategies # supported for Performance Max campaigns. # An optional ROAS (Return on Advertising Spend) can be set for # maximizeConversionValue. The ROAS value must be specified as a ratio in # the API. It is calculated by dividing "total value" by "total spend". # For more information on Maximize Conversion Value, see the support # article: http://support.google.com/google-ads/answer/7684216. # A targetRoas of 3.5 corresponds to a 350% return on ad spend. maximizeConversionValue => Google::Ads::GoogleAds::V25::Common::MaximizeConversionValue-> new({ targetRoas => 3.5 } ), # Set if the campaign is enabled for brand guidelines. For more information # on brand guidelines, see https://support.google.com/google-ads/answer/14934472. brandGuidelinesEnabled => $brand_guidelines_enabled, # Configures the optional opt-in/out status for asset automation settings. assetAutomationSettings => $asset_automation_settings, # Set the text guidelines. textGuidelines => $text_guidelines, # Optional fields. startDateTime => strftime("%Y%m%d 00:00:00", localtime(time + 60 * 60 * 24)), endDateTime => strftime( "%Y%m%d 23:59:59", localtime(time + 60 * 60 * 24 * 365) ), # Declare whether or not this campaign serves political ads targeting the EU. # Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and # DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING. containsEuPoliticalAdvertising => DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING })})}); }
curl
입찰 전략 전환
캠페인의 입찰 전략을 업데이트하려면
CampaignOperation.update,
앞에서 설명한 대로 Campaign의 필드를 설정합니다.
입찰 전략에 예산 맞추기
입찰 전략에 예산을 맞추려면 다음 두 가지 조건을 충족해야 합니다.
- 대칭 정렬 전환: 정렬되는 예산과 전략이 서로를 참조해야 합니다. 이전에는 다른 파트너와 정렬된 항목이 있는 경우 동일한 트랜잭션 내에서 이러한 연결되지 않은 파트너도 명시적으로 업데이트(삭제 또는 다른 항목에 할당)하여 이전 연결을 깔끔하게 끊어야 합니다.
- 동일한 캠페인 집합: 예산과 전략이 정확히 동일한 캠페인 집합에 적용되어야 합니다. 두 항목이 현재 사용되지 않는 경우 이 집합은 비어 있을 수 있습니다.
중요한 점은 이러한 모든 변경사항이 단일 GoogleAdsService.Mutate 호출 내에서 원자적으로 실행되어야 한다는 것입니다. 예산과 전략을 정렬할 때 백엔드에서 동일한 캠페인을 볼 수 있도록 하려면 캠페인 연결을 수정하는 작업이 mutateOperations 목록에서 예산 및 전략 정렬을 수정하는 작업보다 먼저 표시되어야 합니다.
예를 들어 Budget1이 Strategy1과 정렬되고 Budget2가 Strategy2와 정렬된다고 가정해 보겠습니다. 정렬을 변경하고 Budget1을 Strategy2와 직접 연결하려면 다음 작업을 순서대로 실행하는 일괄 변형 요청을 구성합니다.
- 연결되지 않은 정렬 삭제: 업데이트를 전송하여 연결되지 않은 항목 (
Strategy1및Budget2)의 정렬 필드를 삭제합니다. - 캠페인 재할당:
Campaign1및Campaign2가Strategy2를 가리키도록 업데이트합니다. - 정렬: 각 정렬 필드를 업데이트하여 서로를 가리키도록 함으로써
Budget1을Strategy2와 직접 연결합니다.