타겟팅 설정

타겟팅 설정 사용 광고 그룹 또는 캠페인에 따라 특정 잠재고객 세그먼트 또는 선택한 특정 콘텐츠에 적용할 수 있습니다

다양한 기준 유형이 타겟팅에 사용되는 방식에 대한 세부정보를 설정할 수 있습니다. TargetingSetting 필드를 다음과 같이 설정합니다. 배열 target_restrictionsTargetRestriction를 사용하면 기준 유형이 bid_only 옵션 중에서 선택할 수 있습니다.

bid_onlytrue로 설정하면 타겟팅 설정이 다음과 같이 설정됩니다. 트래픽을 제한하는 데 기준이 사용되지 않지만 리마케팅 목록의 사용자에 따라 입찰가를 다르게 설정할 수 있습니다. 설정 bid_only에서 false로 지정하면 타겟팅 설정이 '타겟팅'으로 설정됩니다. 이를 통해 타겟팅 목록에 있는 사용자로만 광고그룹 트래픽을 제한할 수 있습니다.

권장사항

기본적으로 bid_onlyfalse로 설정되어 있으므로 타겟팅 설정이 '타겟팅'으로 설정해야 합니다 검색 또는 쇼핑 캠페인을 사용하는 경우 bid_only의 타겟팅 설정을 다음으로 변경해 보세요. true: '관찰'로 설정합니다.

검색 광고의 잠재고객 세그먼트에 대해 중복 캠페인을 설정하는 경우 bid_only의 타겟팅을 false로 유지합니다.

제한사항

추가하거나 업데이트할 수 없습니다. AdGrouptargeting_setting targeting_setting가 확인할 수 있습니다. targeting_setting가 상위 Campaign에 설정된 경우 다음을 실행합니다. 먼저 상위 Campaigntargeting_setting를 삭제해야 합니다. 마찬가지로 먼저 AdGroup에서 targeting_setting를 삭제해야 Campaign에서 확인해 보세요.

타겟팅 설정을 가져옵니다.

타겟팅이 의도한 대로 설정되어 있는지 확인하려면 광고 그룹 또는 캠페인에 대해 targeting_setting ad_group.targeting_setting.target_restrictions 검색 쿼리에 있는 ad_group 리소스의 필드

이 예에서는 광고그룹의 targeting_setting를 업데이트하여 bid_onlyTargetRestriction 인스턴스의 경우 targeting_dimensiontrue인 경우 AUDIENCE, 해당 광고그룹의 광고가 지정된 잠재고객 세그먼트를 찾을 수 있습니다.

먼저, 다음 위치에서 모든 ad_group.targeting_setting.target_restrictions를 가져옵니다. 광고그룹을 선택합니다.

String searchQuery =
   
"SELECT ad_group.id, ad_group.name, ad_group.targeting_setting.target_restrictions "
       
+ "FROM ad_group "
       
+ "WHERE ad_group.id = "
       
+ adGroupId;
     
string query = $@"
    SELECT ad_group.id, ad_group.name, ad_group.targeting_setting.target_restrictions
    FROM ad_group
    WHERE ad_group.id = {adGroupId}"
;
     
$query = "SELECT ad_group.id, ad_group.name, " .
   
"ad_group.targeting_setting.target_restrictions " .
   
"FROM ad_group " .
   
"WHERE ad_group.id = $adGroupId";
     
query = f"""
    SELECT
      ad_group.id,
      ad_group.name,
      ad_group.targeting_setting.target_restrictions
    FROM ad_group
    WHERE ad_group.id = {ad_group_id}"""

     
query = <<~QUERY
  SELECT ad_group
.id, ad_group.name,
         ad_group
.targeting_setting.target_restrictions
  FROM ad_group
  WHERE ad_group
.id = #{ad_group_id}
QUERY

     
my $query =
 
"SELECT ad_group.id, ad_group.name, " .
 
"ad_group.targeting_setting.target_restrictions FROM ad_group " .
 
"WHERE ad_group.id = $ad_group_id";
     

다음으로, 타겟 제한을 루프 처리하여 TargetingSetting 객체. 코드에서 TargetRestriction AUDIENCEtargeting_dimensionfalsebid_only 값인 경우 TargetRestriction 객체의 bid_only 필드를 true로 업데이트합니다. 또는 'Observation')을 만들고 TargetingSetting 객체에 추가합니다.

그 외의 경우에는 서버에서 반환된 TargetRestriction 객체를 TargetingSetting입니다. 다시 구성하고 전달해야 하는 전체 TargetingSetting 객체를 Google Ads로 반환합니다. Google은 사용자가 TargetingSetting에서 누락된 target_restrictions는 삭제해야 합니다.

for (TargetRestriction targetRestriction : targetRestrictions) {
 
TargetingDimension targetingDimension = targetRestriction.getTargetingDimension();
 
boolean bidOnly = targetRestriction.getBidOnly();
 
System.out.printf(
     
"- Targeting restriction with targeting dimension '%s' and bid only set to '%b'.%n",
      targetingDimension
, bidOnly);
 
// Adds the target restriction to the TargetingSetting object as is if the targeting
 
// dimension has a value other than AUDIENCE because those should not change.
 
if (!targetingDimension.equals(TargetingDimension.AUDIENCE)) {
    targetingSettingBuilder
.addTargetRestrictions(targetRestriction);
 
} else if (!bidOnly) {
    shouldUpdateTargetingSetting
= true;
   
// Adds an AUDIENCE target restriction with bid_only set to true to the targeting
   
// setting object. This has the effect of setting the AUDIENCE target restriction to
   
// "Observation". For more details about the targeting setting, visit
   
// https://support.google.com/google-ads/answer/7365594.
    targetingSettingBuilder
.addTargetRestrictions(
       
TargetRestriction.newBuilder()
           
.setTargetingDimensionValue(TargetingDimension.AUDIENCE_VALUE)
           
.setBidOnly(true));
 
}
}
     
foreach (TargetRestriction targetRestriction in targetRestrictions)
{
   
TargetingDimension targetingDimension =
        targetRestriction
.TargetingDimension;
   
bool bidOnly = targetRestriction.BidOnly;

   
Console.WriteLine("\tTargeting restriction with targeting dimension " +
        $
"'{targetingDimension}' and bid only set to '{bidOnly}'.");

   
// Add the target restriction to the TargetingSetting object as is if the
   
// targeting dimension has a value other than AUDIENCE because those should
   
// not change.
   
if (targetingDimension != TargetingDimension.Audience)
   
{
        targetingSetting
.TargetRestrictions.Add(targetRestriction);
   
}
   
else if (!bidOnly)
   
{
        shouldUpdateTargetingSetting
= true;

       
// Add an AUDIENCE target restriction with bid_only set to true to the
       
// targeting setting object. This has the effect of setting the AUDIENCE
       
// target restriction to "Observation". For more details about the
       
// targeting setting, visit
       
// https://support.google.com/google-ads/answer/7365594.
        targetingSetting
.TargetRestrictions.Add(new TargetRestriction
       
{
           
TargetingDimension = TargetingDimension.Audience,
           
BidOnly = true
       
});
   
}
}
     
foreach (
    $adGroup
->getTargetingSetting()->getTargetRestrictions() as $targetRestriction
) {
   
// Prints the results.
    $targetingDimension
= $targetRestriction->getTargetingDimension();
    $bidOnly
= $targetRestriction->getBidOnly();
    printf
(
       
"- Targeting restriction with targeting dimension '%s' and bid only set to " .
       
"'%s'.%s",
       
TargetingDimension::name($targetingDimension),
        $bidOnly
? 'true' : 'false',
        PHP_EOL
   
);

   
// Adds the target restriction to the TargetingSetting object as is if the targeting
   
// dimension has a value other than AUDIENCE because those should not change.
   
if ($targetingDimension !== TargetingDimension::AUDIENCE) {
        $targetRestrictions
[] = $targetRestriction;
   
} elseif (!$bidOnly) {
        $shouldUpdateTargetingSetting
= true;

       
// Adds an AUDIENCE target restriction with bid_only set to true to the
       
// targeting setting object. This has the effect of setting the AUDIENCE
       
// target restriction to "Observation".
       
// For more details about the targeting setting, visit
       
// https://support.google.com/google-ads/answer/7365594.
        $targetRestrictions
[] = new TargetRestriction([
           
'targeting_dimension' => TargetingDimension::AUDIENCE,
           
'bid_only' => true
       
]);
   
}
}
     
for target_restriction in target_restrictions:
    targeting_dimension
= target_restriction.targeting_dimension
    bid_only
= target_restriction.bid_only

   
print(
       
"\tTargeting restriction with targeting dimension "
        f
"'{targeting_dimension.name}' "
        f
"and bid only set to '{bid_only}'."
   
)

   
# Add the target restriction to the TargetingSetting object as
   
# is if the targeting dimension has a value other than audience
   
# because those should not change.
   
if targeting_dimension != targeting_dimension_enum.AUDIENCE:
        targeting_setting
.target_restrictions.append(target_restriction)
   
elif not bid_only:
        should_update_targeting_setting
= True

       
# Add an audience target restriction with bid_only set to
       
# true to the targeting setting object. This has the effect
       
# of setting the audience target restriction to
       
# "Observation". For more details about the targeting
       
# setting, visit
       
# https://support.google.com/google-ads/answer/7365594.
        new_target_restriction
= targeting_setting.target_restrictions.add()
        new_target_restriction
.targeting_dimension = (
            targeting_dimension_enum
.AUDIENCE
       
)
        new_target_restriction
.bid_only = True
     
ad_group.targeting_setting.target_restrictions.each do |r|
 
# Prints the results.
  targeting_dimension
= r.targeting_dimension
  bid_only
= r.bid_only
  puts
"- Targeting restriction with targeting dimension " \
   
"#{targeting_dimension} and bid only set to #{bid_only}."

 
# Adds the target restriction to the TargetingSetting object as is if the
 
# targeting dimension has a value other than AUDIENCE because those should
 
# not change.
 
if targeting_dimension != :AUDIENCE
    target_restrictions
<< r
 
elsif !bid_only
    should_update_targeting_setting
= true

   
# Adds an AUDIENCE target restriction with bid_only set to true to the
   
# targeting setting object. This has the effect of setting the AUDIENCE
   
# target restriction to "Observation".
   
# For more details about the targeting setting, visit
   
# https://support.google.com/google-ads/answer/7365594.
    target_restrictions
<< client.resource.target_restriction do |tr|
      tr
.targeting_dimension = :AUDIENCE
      tr
.bid_only = true
   
end
 
end
end
     
foreach my $target_restriction (@target_restrictions) {
 
my $targeting_dimension = $target_restriction->{targetingDimension};

  printf
   
"\tTargeting restriction with targeting dimension '%s' and bid " .
   
"only set to '%s'.\n",
    $targeting_dimension
,
    $target_restriction
->{bidOnly} ? "TRUE" : "FALSE";

 
# Add the target restriction to the TargetingSetting object as is if the
 
# targeting dimension has a value other than AUDIENCE because those
 
# should not change.
 
if ($targeting_dimension ne AUDIENCE) {
    $target_restriction
->{bidOnly} =
      $target_restriction
->{bidOnly} ? "true" : "false";
    push
@{$targeting_setting->{targetRestrictions}}, $target_restriction;
 
} elsif (!$target_restriction->{bidOnly}) {
    $should_update_target_setting
= 1;

   
# Add an AUDIENCE target restriction with bid_only set to true to the
   
# targeting setting object. This has the effect of setting the
   
# AUDIENCE target restriction to "Observation". For more details about
   
# the targeting setting, visit
   
# https://support.google.com/google-ads/answer/7365594.
   
my $new_restriction =
     
Google::Ads::GoogleAds::V17::Common::TargetRestriction->new({
        targetingDimension
=> AUDIENCE,
        bidOnly            
=> "true"
     
});
    push
@{$targeting_setting->{targetRestrictions}}, $new_restriction;
 
}
}
     

마지막으로 코드가 업데이트가 필요한 타겟 제한에 도달하면 새 타겟팅 설정으로 광고그룹을 업데이트합니다.

private void updateTargetingSetting(
   
GoogleAdsClient googleAdsClient,
   
long customerId,
   
long adGroupId,
   
TargetingSetting targetingSetting) {
 
// Creates the ad group service client.
 
try (AdGroupServiceClient adGroupServiceClient =
      googleAdsClient
.getLatestVersion().createAdGroupServiceClient()) {
   
// Creates an ad group object with the proper resource name and updated targeting setting.
   
AdGroup adGroup =
       
AdGroup.newBuilder()
           
.setResourceName(ResourceNames.adGroup(customerId, adGroupId))
           
.setTargetingSetting(targetingSetting)
           
.build();
   
// Constructs an operation that will update the ad group, using the FieldMasks utility to
   
// derive the update mask. This mask tells the Google Ads API which attributes of the
   
// ad group you want to change.
   
AdGroupOperation operation =
       
AdGroupOperation.newBuilder()
           
.setUpdate(adGroup)
           
.setUpdateMask(FieldMasks.allSetFieldsOf(adGroup))
           
.build();
   
// Sends the operation in a mutate request.
   
MutateAdGroupsResponse response =
        adGroupServiceClient
.mutateAdGroups(
           
Long.toString(customerId), ImmutableList.of(operation));
   
// Prints the resource name of the updated object.
   
System.out.printf(
       
"Updated targeting setting of ad group with resource name '%s'; set the AUDIENCE "
           
+ "target restriction to 'Observation'.%n",
        response
.getResults(0).getResourceName());
 
}
}
     
private void UpdateTargetingSetting(GoogleAdsClient client, long customerId, long
    adGroupId
, TargetingSetting targetingSetting)
{
   
// Get the AdGroupService client.
   
AdGroupServiceClient adGroupServiceClient =
        client
.GetService(Services.V17.AdGroupService);

   
// Create an ad group object with the updated targeting setting.
   
AdGroup adGroup = new AdGroup
   
{
       
ResourceName = ResourceNames.AdGroup(customerId, adGroupId),
       
TargetingSetting = targetingSetting
   
};

   
// Construct an operation that will update the ad group, using the FieldMasks utility
   
// to derive the update mask. This mask tells the Google Ads API which attributes of the
   
// ad group you want to change.
   
AdGroupOperation operation = new AdGroupOperation
   
{
       
Update = adGroup,
       
UpdateMask = FieldMasks.AllSetFieldsOf(adGroup)
   
};

   
// Send the operation in a mutate request.
   
MutateAdGroupsResponse response =
        adGroupServiceClient
.MutateAdGroups(customerId.ToString(), new[] { operation });
   
// Print the resource name of the updated object.
   
Console.WriteLine("Updated targeting setting of ad group with resource name " +
        $
"'{response.Results.First().ResourceName}'; set the AUDIENCE target restriction " +
       
"to 'Observation'.");
}
     
private static function updateTargetingSetting(
   
GoogleAdsClient $googleAdsClient,
   
int $customerId,
   
int $adGroupId,
   
TargetingSetting $targetingSetting
) {
   
// Creates an ad group object with the proper resource name and updated targeting setting.
    $adGroup
= new AdGroup([
       
'resource_name' => ResourceNames::forAdGroup($customerId, $adGroupId),
       
'targeting_setting' => $targetingSetting
   
]);

   
// Constructs an operation that will update the ad group with the specified resource name,
   
// using the FieldMasks utility to derive the update mask. This mask tells the Google Ads
   
// API which attributes of the ad group you want to change.
    $adGroupOperation
= new AdGroupOperation();
    $adGroupOperation
->setUpdate($adGroup);
    $adGroupOperation
->setUpdateMask(FieldMasks::allSetFieldsOf($adGroup));

   
// Issues a mutate request to update the ad group.
    $adGroupServiceClient
= $googleAdsClient->getAdGroupServiceClient();
    $response
= $adGroupServiceClient->mutateAdGroups(
       
MutateAdGroupsRequest::build($customerId, [$adGroupOperation])
   
);

   
// Prints the resource name of the updated ad group.
    printf
(
       
"Updated targeting setting of ad group with resource name '%s'; set the AUDIENCE " .
       
"target restriction to 'Observation'.%s",
        $response
->getResults()[0]->getResourceName(),
        PHP_EOL
   
);
}
     
def update_targeting_setting(
    client
, customer_id, ad_group_id, targeting_setting
):
   
"""Updates the given TargetingSetting of an ad group.

    Args:
        client: The Google Ads client.
        customer_id: The Google Ads customer ID.
        ad_group_id: The ad group ID for which to update the audience targeting
            restriction.
        targeting_setting: The updated targeting setting.
    """

   
# Get the AdGroupService client.
    ad_group_service
= client.get_service("AdGroupService")

   
# Construct an operation that will update the ad group.
    ad_group_operation
= client.get_type("AdGroupOperation")

   
# Populate the ad group object with the updated targeting setting.
    ad_group
= ad_group_operation.update
    ad_group
.resource_name = ad_group_service.ad_group_path(
        customer_id
, ad_group_id
   
)
    ad_group
.targeting_setting.target_restrictions.extend(
        targeting_setting
.target_restrictions
   
)
   
# Use the field_mask utility to derive the update mask. This mask tells the
   
# Google Ads API which attributes of the ad group you want to change.
    client
.copy_from(
        ad_group_operation
.update_mask,
        protobuf_helpers
.field_mask(None, ad_group._pb),
   
)

   
# Send the operation in a mutate request and print the resource name of the
   
# updated object.
    mutate_ad_groups_response
= ad_group_service.mutate_ad_groups(
        customer_id
=customer_id, operations=[ad_group_operation]
   
)
   
print(
       
"Updated targeting setting of ad group with resource name "
        f
"'{mutate_ad_groups_response.results[0].resource_name}'; set the "
       
"audience target restriction to 'Observation'."
   
)
     
def update_targeting_setting(
  client
,
  customer_id
,
  ad_group_id
,
  targeting_setting
)
 
# Constructs an operation that will update the ad group with the specified
 
# resource name.
  ad_group_resource_name
= client.path.ad_group(customer_id, ad_group_id)
  operation
= client.operation.update_resource.ad_group(ad_group_resource_name) do |ag|
    ag
.targeting_setting = targeting_setting
 
end

 
# Issues a mutate request to update the ad group.
  response
= client.service.ad_group.mutate_ad_groups(
    customer_id
: customer_id,
    operations
: [operation],
 
)

 
# Prints the resource name of the updated ad group.
  puts
"Updated targeting setting of ad group with resource name " \
   
"#{response.results.first.resource_name}; set the AUDIENCE target " \
   
"restriction to 'Observation'."
end
     
sub update_targeting_setting {
 
my ($api_client, $customer_id, $ad_group_id, $targeting_setting) = @_;

 
# Construct an ad group object with the updated targeting setting.
 
my $ad_group = Google::Ads::GoogleAds::V17::Resources::AdGroup->new({
      resourceName
=>
       
Google::Ads::GoogleAds::V17::Utils::ResourceNames::ad_group(
        $customer_id
, $ad_group_id
       
),
      targetingSetting
=> $targeting_setting
   
});

 
# Create an operation that will update the ad group, using the FieldMasks
 
# utility to derive the update mask. This mask tells the Google Ads API which
 
# attributes of the ad group you want to change.
 
my $ad_group_operation =
   
Google::Ads::GoogleAds::V17::Services::AdGroupService::AdGroupOperation->
   
new({
      update    
=> $ad_group,
      updateMask
=> all_set_fields_of($ad_group)});

 
# Send the operation in a mutate request and print the resource name of the
 
# updated resource.
 
my $ad_groups_response = $api_client->AdGroupService()->mutate({
      customerId
=> $customer_id,
      operations
=> [$ad_group_operation]});

  printf
"Updated targeting setting of ad group with resourceName " .
   
"'%s'; set the AUDIENCE target restriction to 'Observation'.\n",
    $ad_groups_response
->{results}[0]{resourceName};
}
     

캠페인의 bid_only 필드를 설정하는 프로세스는 거의 동일합니다.