टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) सेटिंग

टारगेटिंग सेटिंग का इस्तेमाल करें आपके विज्ञापन समूह या अभियान यह निर्दिष्ट कर सकते हैं कि आपके विज्ञापनों को केवल दिखाने के लिए सीमित करना है या नहीं या आपके चुने गए कॉन्टेंट पर लागू हो.

टारगेटिंग सेटिंग सेट अप करना

टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) के लिए, अलग-अलग तरह की शर्तों का इस्तेमाल कैसे किया जाता है, इसके बारे में जानकारी सेट अप की जा सकती है TargetingSetting फ़ील्ड को इसका कलेक्शन target_restrictions. हर TargetRestriction से, कंट्रोल करने की सुविधा मिलती है कि क्या एक तरह का मानदंड bid_only विकल्प है या नहीं.

bid_only को true पर सेट करने पर टारगेटिंग सेटिंग इस पर सेट होगी "निगरानी" और मानदंड का इस्तेमाल ट्रैफ़िक को सीमित करने के लिए नहीं किया जाएगा, लेकिन आपको अपनी सूचियों पर अलग-अलग उपयोगकर्ताओं के लिए अलग-अलग बोली लगाने की अनुमति मिलती है. सेटिंग bid_only से false टारगेटिंग सेटिंग को "टारगेटिंग" पर सेट कर देता है और यह सुविधा चालू करती है सिर्फ़ टारगेट की गई सूची में मौजूद उपयोगकर्ताओं के लिए विज्ञापन ग्रुप ट्रैफ़िक को सीमित करने की शर्तें.

सबसे सही तरीके

डिफ़ॉल्ट रूप से, bid_only को false पर सेट किया जाता है. इसका मतलब है कि टारगेटिंग सेटिंग "टारगेटिंग" पर सेट होनी चाहिए. अगर किसी सर्च कैंपेन में ऑडियंस सेगमेंट जोड़े जा रहे हैं या शॉपिंग अभियान, bid_only की लक्ष्यीकरण सेटिंग को इसे "निगरानी" पर सेट करने के लिए, true.

अगर आपको Search Network में दिखने वाले विज्ञापनों के ऑडियंस सेगमेंट के लिए डुप्लीकेट कैंपेन सेट अप करना है, तो bid_only की टारगेटिंग को false पर सेट रखें.

पाबंदियां

आपके पास इसे जोड़ने या अपडेट करने का विकल्प नहीं है AdGroup से targeting_setting के लिए अगर targeting_setting को पैरंट कैंपेन. अगर targeting_setting को पैरंट Campaign पर सेट किया गया है, तो को पहले पैरंट Campaign पर मौजूद targeting_setting को हटाना होगा. इसी तरह, सेट करने के लिए आपको सबसे पहले AdGroup पर मौजूद targeting_setting को हटाना होगा Campaign पर रिकॉर्ड किया था.

टारगेटिंग सेटिंग वापस पाएं

टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) आपके हिसाब से सेट अप हुई है या नहीं, इसकी पुष्टि करने के लिए targeting_setting का अनुरोध करके विज्ञापन ग्रुप या कैंपेन ad_group.targeting_setting.target_restrictions फ़ील्ड में डालें.ad_group

उदाहरण

इस उदाहरण में विज्ञापन ग्रुप के targeting_setting को अपडेट किया गया है, ताकि bid_only है, TargetRestriction इंस्टेंस के लिए true. इसके targeting_dimension AUDIENCE, यह सुनिश्चित करना कि विज्ञापन समूह के विज्ञापन केवल का इस्तेमाल किया जा सकता है.

सबसे पहले, इससे सभी ad_group.targeting_setting.target_restrictions वापस पाएं दिए गए आईडी वाला विज्ञापन ग्रुप.

Java

String searchQuery =
    "SELECT ad_group.id, ad_group.name, ad_group.targeting_setting.target_restrictions "
        + "FROM ad_group "
        + "WHERE ad_group.id = "
        + adGroupId;
      

C#

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

PHP

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

Python

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}"""
      

Ruby

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
      

Perl

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 AUDIENCE का targeting_dimension और false का bid_only मान है, तो यह TargetRestriction ऑब्जेक्ट के bid_only फ़ील्ड को true पर अपडेट करता है (या "निगरानी") जोड़ें और उसे हमारे TargetingSetting ऑब्जेक्ट में जोड़ें.

नहीं तो, TargetRestriction ऑब्जेक्ट को सर्वर से लौटाए गए के तौर पर TargetingSetting. यह ध्यान रखना ज़रूरी है कि आपको इसे नए सिरे से बनाना होगा और इसे पूरा करना होगा पूरा TargetingSetting ऑब्जेक्ट वापस Google Ads पर ले जाएं. Google यह मानता है कि TargetingSetting में से target_restrictions को हटा दिया जाना चाहिए.

Java

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));
  }
}
      

C#

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
        });
    }
}
      

PHP

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
        ]);
    }
}
      

Python

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
      

Ruby

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
      

Perl

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;
  }
}
      

आखिर में, अगर कोड को टारगेट करने से जुड़ी कोई ऐसी पाबंदी मिलती है जिसे अपडेट करने की ज़रूरत है, तो विज्ञापन ग्रुप को नई टारगेटिंग सेटिंग से अपडेट करता है.

Java

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());
  }
}
      

C#

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'.");
}
      

PHP

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
    );
}
      

Python

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'."
    )
      

Ruby

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
      

Perl

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 फ़ील्ड को सेट करने की प्रक्रिया करीब-करीब एक जैसी है.