数据排除是一款高级工具,可用于告知智能出价忽略账号转化跟踪出现问题期间的所有数据。如需详细了解数据排除功能的运作方式,请参阅数据排除帮助页面。
使用 BiddingDataExclusions
以编程方式创建数据排除项。
范围
BiddingDataExclusions
有一个必需的 scope
,可设置为以下值。其他特定于镜区的配置选项会根据使用的镜区进行设置。
CAMPAIGN
- 排除对象应用于特定广告系列。将campaigns
字段设置为要应用此排除对象的广告系列资源名称列表。- 每个
BiddingDataExclusion
的广告系列数量上限为 2,000 个。
- 每个
CHANNEL
- 排除对象会应用于属于特定渠道类型的广告系列。将advertising_channel_types
字段设置为要应用此排除项的AdvertisingChannelTypes
列表。
设备
除了范围之外,数据排除项还可以通过可选的设备类型列表进行配置,以便将排除项应用于这些设备类型。如果设置了 devices
,则系统只会排除指定设备类型的转化数据。如果未指定,系统会排除所有类型设备的转化数据。
日期和时间
除了范围和可选设备之外,每个数据排除项都必须具有开始日期和时间以及结束日期和时间。数据排除项具有回溯性,应用于过去具有 start_date_time
且过去或将来具有 end_date_time
的事件。时间以账号所在时区为准。
示例
以下示例展示了如何创建 CHANNEL
范围的数据排除项。
注释掉的部分演示了如果您要改为设置 CAMPAIGN
范围,该如何指定广告系列。
Java
BiddingDataExclusion DataExclusion = BiddingDataExclusion.newBuilder() // A unique name is required for every data exclusion. .setName("Data exclusion #" + getPrintableDateTime()) // The CHANNEL scope applies the data exclusion to all campaigns of specific // advertising channel types. In this example, the exclusion will only apply to // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific // campaigns. .setScope(SeasonalityEventScope.CHANNEL) .addAdvertisingChannelTypes(AdvertisingChannelType.SEARCH) // If setting scope CAMPAIGN, add individual campaign resource name(s) according to // the commented out line below. // .addCampaigns("INSERT_CAMPAIGN_RESOURCE_NAME_HERE") .setStartDateTime(startDateTime) .setEndDateTime(endDateTime) .build(); BiddingDataExclusionOperation operation = BiddingDataExclusionOperation.newBuilder().setCreate(DataExclusion).build(); MutateBiddingDataExclusionsResponse response = DataExclusionServiceClient.mutateBiddingDataExclusions( customerId.toString(), ImmutableList.of(operation)); System.out.printf( "Added data exclusion with resource name: %s%n", response.getResults(0).getResourceName());
C#
BiddingDataExclusion dataExclusion = new BiddingDataExclusion() { // A unique name is required for every data exclusion. Name = "Data exclusion #" + ExampleUtilities.GetRandomString(), // The CHANNEL scope applies the data exclusion to all campaigns of specific // advertising channel types. In this example, the the exclusion will only apply to // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific // campaigns. Scope = SeasonalityEventScope.Channel, AdvertisingChannelTypes = { AdvertisingChannelType.Search }, // The date range should be less than 14 days. StartDateTime = startDateTime, EndDateTime = endDateTime, }; BiddingDataExclusionOperation operation = new BiddingDataExclusionOperation() { Create = dataExclusion }; try { MutateBiddingDataExclusionsResponse response = biddingDataExclusionService.MutateBiddingDataExclusions( customerId.ToString(), new[] { operation }); Console.WriteLine($"Added data exclusion with resource name: " + $"{response.Results[0].ResourceName}"); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; }
PHP
// Creates a bidding data exclusion. $dataExclusion = new BiddingDataExclusion([ // A unique name is required for every data exclusion. 'name' => 'Data exclusion #' . Helper::getPrintableDatetime(), // The CHANNEL scope applies the data exclusion to all campaigns of specific // advertising channel types. In this example, the exclusion will only apply to // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific // campaigns. 'scope' => SeasonalityEventScope::CHANNEL, 'advertising_channel_types' => [AdvertisingChannelType::SEARCH], // If setting scope CAMPAIGN, add individual campaign resource name(s) according to // the commented out line below. // 'campaigns' => ['INSERT_CAMPAIGN_RESOURCE_NAME_HERE'], 'start_date_time' => $startDateTime, 'end_date_time' => $endDateTime ]); // Creates a bidding data exclusion operation. $biddingDataExclusionOperation = new BiddingDataExclusionOperation(); $biddingDataExclusionOperation->setCreate($dataExclusion); // Submits the bidding data exclusion operation to add the bidding data exclusion. $biddingDataExclusionServiceClient = $googleAdsClient->getBiddingDataExclusionServiceClient(); $response = $biddingDataExclusionServiceClient->mutateBiddingDataExclusions( MutateBiddingDataExclusionsRequest::build($customerId, [$biddingDataExclusionOperation]) ); printf( "Added bidding data exclusion with resource name: '%s'.%s", $response->getResults()[0]->getResourceName(), PHP_EOL );
Python
bidding_data_exclusion_service = client.get_service( "BiddingDataExclusionService" ) operation = client.get_type("BiddingDataExclusionOperation") bidding_data_exclusion = operation.create # A unique name is required for every data exclusion bidding_data_exclusion.name = f"Data exclusion #{uuid4()}" # The CHANNEL scope applies the data exclusion to all campaigns of specific # advertising channel types. In this example, the exclusion will only # apply to Search campaigns. Use the CAMPAIGN scope to instead limit the # scope to specific campaigns. bidding_data_exclusion.scope = ( client.enums.SeasonalityEventScopeEnum.CHANNEL ) bidding_data_exclusion.advertising_channel_types.append( client.enums.AdvertisingChannelTypeEnum.SEARCH ) # If setting scope CAMPAIGN, add individual campaign resource name(s) # according to the commented out line below. # # bidding_data_exclusion.campaigns.append( # "INSERT_CAMPAIGN_RESOURCE_NAME_HERE" # ) bidding_data_exclusion.start_date_time = start_date_time bidding_data_exclusion.end_date_time = end_date_time response = bidding_data_exclusion_service.mutate_bidding_data_exclusions( customer_id=customer_id, operations=[operation] ) resource_name = response.results[0].resource_name print(f"Added data exclusion with resource name: '{resource_name}'")
Ruby
client = Google::Ads::GoogleAds::GoogleAdsClient.new operation = client.operation.create_resource.bidding_data_exclusion do |bda| # A unique name is required for every data excluseion. bda.name = "Seasonality Adjustment #{(Time.new.to_f * 1000).to_i}" # The CHANNEL scope applies the data exclusion to all campaigns of specific # advertising channel types. In this example, the conversion_rate_modifier # will only apply to Search campaigns. Use the CAMPAIGN scope to instead # limit the scope to specific campaigns. bda.scope = :CHANNEL bda.advertising_channel_types << :SEARCH # If setting scope CAMPAIGN, add individual campaign resource name(s) # according to the commented out line below. # # bda.campaigns << "INSERT_CAMPAIGN_RESOURCE_NAME_HERE" bda.start_date_time = start_date_time bda.end_date_time = end_date_time end response = client.service.bidding_data_exclusion.mutate_bidding_data_exclusions( customer_id: customer_id, operations: [operation], ) puts "Added data exclusion with resource name #{response.results.first.resource_name}."
Perl
my $data_exclusion = Google::Ads::GoogleAds::V18::Resources::BiddingDataExclusion->new({ # A unique name is required for every data exclusion. name => "Data exclusion #" . uniqid(), # The CHANNEL scope applies the data exclusion to all campaigns of specific # advertising channel types. In this example, the exclusion will only apply # to Search campaigns. Use the CAMPAIGN scope to instead limit the scope to # specific campaigns. scope => CHANNEL, advertisingChannelTypes => [SEARCH], # If setting scope CAMPAIGN, add individual campaign resource name(s) # according to the commented out line below. # campaigns => ["INSERT_CAMPAIGN_RESOURCE_NAME_HERE"], startDateTime => $start_date_time, endDateTime => $end_date_time }); my $operation = Google::Ads::GoogleAds::V18::Services::BiddingDataExclusionService::BiddingDataExclusionOperation ->new({ create => $data_exclusion }); my $response = $api_client->BiddingDataExclusionService()->mutate({ customerId => $customer_id, operations => [$operation]}); printf "Added data exclusion with resource name: '%s'.\n", $response->{results}[0]{resourceName};