टारगेटिंग सेटिंग कॉन्फ़िगर करना

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

उदाहरण के लिए, ऑडियंस टारगेटिंग की मदद से यह तय किया जा सकता है कि आपको किन लोगों तक पहुंचना है.

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

`TargetingSetting` फ़ील्ड को `target_restrictions` की एक कलेक्शन के साथ सेट करके, यह तय किया जा सकता है कि टारगेटिंग के लिए, अलग-अलग तरह की ज़रूरी शर्तों का इस्तेमाल कैसे किया जाए. इसके अलावा, `target_restriction_operations` का इस्तेमाल करके, धीरे-धीरे अपडेट लागू किए जा सकते हैं. हर `TargetRestriction` की मदद से, यह कंट्रोल किया जा सकता है कि `TargetingDimension` (`AUDIENCE`, `TOPIC`, `GENDER`, `AGE_RANGE`, `PLACEMENT`, `PARENTAL_STATUS` या `INCOME_RANGE`) में `bid_only` विकल्प का इस्तेमाल किया जाए या नहीं.TargetingSettingtarget_restrictionstarget_restriction_operationsTargetRestrictionTargetingDimensionAUDIENCETOPICGENDERAGE_RANGEPLACEMENTPARENTAL_STATUSINCOME_RANGEbid_only

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

मुख्य अंतरों की खास जानकारी, यहां दी गई टेबल में दी गई है:

सेटिंग bid_only पहुंच पर असर बिडिंग पर असर
टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) false पहुंच को सिर्फ़ चुनी गई ज़रूरी शर्तों तक सीमित करता है ज़रूरी शर्तों के लिए खास बिड सेट की जा सकती हैं
निगरानी true पहुंच को सीमित नहीं करता; विज्ञापन सामान्य तरीके से दिखते हैं ज़रूरी शर्तों के लिए बिड घटाने या बढ़ाने की सुविधा देता है

प्रैक्टिकल स्थितियां

निगरानी मोड और टारगेटिंग मोड का इस्तेमाल कब करना चाहिए, इसके कुछ उदाहरण यहां दिए गए हैं:

निगरानी
अगर आपने सर्च कैंपेन चलाया है और आपको यह जानना है कि सामान्य लोगों की तुलना में, किसी खास ऑडियंस (उदाहरण के लिए, "खेल के प्रशंसक") से कितने कन्वर्ज़न मिलते हैं, तो निगरानी मोड का इस्तेमाल करें. इससे आपके विज्ञापन सिर्फ़ उस ऑडियंस को नहीं दिखेंगे. "खेल के प्रशंसक" को bid_only = true (निगरानी) के साथ, ऑडियंस की ज़रूरी शर्त के तौर पर जोड़ा जा सकता है. साथ ही, बिड घटाने या बढ़ाने की सुविधा को +10% पर सेट किया जा सकता है. इससे आपको उस ऑडियंस के लिए परफ़ॉर्मेंस डेटा इकट्ठा करने में मदद मिलती है. साथ ही, अगर उस ऑडियंस से अच्छी परफ़ॉर्मेंस मिलती है, तो उसके लिए ज़्यादा प्रतिस्पर्धी बिड सेट की जा सकती हैं. इससे उस ऑडियंस के बाहर के उपयोगकर्ताओं से मिलने वाला ट्रैफ़िक नहीं कम होता.
टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना)
अगर आपने डिसप्ले नेटवर्क पर दिखने वाले विज्ञापन का कैंपेन चलाया है, तो टारगेटिंग मोड का इस्तेमाल करें. इससे उन उपयोगकर्ताओं को रीमार्केटिंग की जा सकती है जिन्होंने पहले आपकी वेबसाइट पर विज़िट किया था, लेकिन कन्वर्ज़न नहीं किया. साथ ही, अगर आपको सिर्फ़ "कार्ट छोड़ने वाले" उपयोगकर्ताओं की सूची में शामिल उपयोगकर्ताओं को ये खास विज्ञापन दिखाने हैं, तो टारगेटिंग मोड का इस्तेमाल करें. इस मामले में, "खरीदारी के बिना कार्ट में सामान छोड़ने वाले" उपयोगकर्ताओं की सूची को bid_only = false (टारगेटिंग) के साथ, UserList की ज़रूरी शर्त के तौर पर जोड़ा जाता है. इससे यह पक्का होता है कि आपके विज्ञापन ग्रुप का बजट, सिर्फ़ खरीदारी की ज़्यादा संभावना वाली ऑडियंस सेगमेंट तक पहुंचने के लिए खर्च किया जाए.

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

डिफ़ॉल्ट रूप से, bid_only को false पर सेट किया जाता है. इसका मतलब है कि टारगेटिंग की सेटिंग "टारगेटिंग" पर सेट होगी. अगर किसी खास टारगेटिंग डाइमेंशन (जैसे कि AUDIENCE) के लिए, टारगेट करने से जुड़ी पाबंदी को TargetingSetting के target_restrictions कलेक्शन से हटा दिया जाता है या वह उसमें मौजूद नहीं होती है, तो सिस्टम उस डाइमेंशन के लिए "टारगेटिंग" के डिफ़ॉल्ट व्यवहार (bid_only का मतलब, false होता है) को अपनाता है.

यह लो-लेवल एपीआई का व्यवहार, Google Ads के यूज़र इंटरफ़ेस (यूआई) से अलग हो सकता है. ऐसा इसलिए, क्योंकि कैंपेन या विज्ञापन ग्रुप बनाते समय, Google Ads का यूआई कुछ टारगेटिंग डाइमेंशन (जैसे कि सर्च कैंपेन के लिए AUDIENCE) के लिए, डिफ़ॉल्ट रूप से "निगरानी" (bid_only का मतलब, true होता है) को अपने-आप लागू कर सकता है. उदाहरण के लिए, यूज़र इंटरफ़ेस (यूआई) के ज़रिए बनाए गए शॉपिंग कैंपेन, एपीआई के नज़रिए से डिफ़ॉल्ट रूप से AUDIENCE डाइमेंशन की सेटिंग को छोड़ सकते हैं. इसका मतलब है कि वे "टारगेटिंग" (bid_only का मतलब, false होता है) के डिफ़ॉल्ट एपीआई व्यवहार को अपने-आप अपना लेते हैं.

अगर Search Network या Shopping Network पर दिखने वाले विज्ञापनों के कैंपेन में, ऑडियंस सेगमेंट जोड़े जा रहे हैं, तो bid_only की टारगेटिंग सेटिंग को साफ़ तौर पर true पर कॉन्फ़िगर करें, ताकि इसे "निगरानी" पर सेट किया जा सके.

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

पाबंदियां

अगर पैरंट कैंपेन में targeting_setting सेट है, तो AdGroup में targeting_setting को जोड़ा या अपडेट नहीं किया जा सकता. अगर पैरंट Campaign में targeting_setting सेट है, तो आपको पहले पैरंट Campaign से targeting_setting को हटाना होगा. इसी तरह, Campaign में सेट करने के लिए, आपको पहले AdGroup से targeting_setting को हटाना होगा.

Campaign या AdGroup से targeting_setting को हटाने के लिए, update ऑपरेशन भेजें. इसमें targeting_setting.target_restrictions को साफ़ किया गया हो (खाली सूची पर सेट किया गया हो) और update_mask में targeting_setting.target_restrictions शामिल हो.

टारगेटिंग की सेटिंग वापस पाना

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

उदाहरण

इस उदाहरण में, किसी विज्ञापन ग्रुप में targeting_setting को अपडेट किया गया है, ताकि bid_only की वैल्यू trueTargetRestrictiontargeting_dimensionAUDIENCE हो. इससे, पहुंच को सीमित किए बिना, ऑडियंस सेगमेंट में शामिल उपयोगकर्ताओं के लिए परफ़ॉर्मेंस देखी जा सकती है और बिड घटाने या बढ़ाने की सुविधा सेट की जा सकती है.

सबसे पहले, दिए गए आईडी वाले विज्ञापन ग्रुप से, सभी 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: str = 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";
      

curl

इसके बाद, टारगेट करने से जुड़ी पाबंदियों के लिए लूप करें और TargetingSetting ऑब्जेक्ट को फिर से बनाएं. अगर कोड को AUDIENCE के targeting_dimension और false की bid_only वैल्यू वाला TargetRestriction मिलता है, तो वह TargetRestriction ऑब्जेक्ट के bid_only फ़ील्ड को true (या "निगरानी") पर अपडेट करता है. साथ ही, उसे TargetingSetting ऑब्जेक्ट में जोड़ता है. इसके अलावा, सर्वर से मिले TargetRestriction ऑब्जेक्ट को TargetingSetting में जोड़ें.

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

target_restriction: TargetRestriction
for target_restriction in target_restrictions:
    targeting_dimension: TargetingDimensionEnum.TargetingDimension = (
        target_restriction.targeting_dimension
    )
    bid_only: bool = 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: bool = 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: TargetRestriction = (
            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::V25::Common::TargetRestriction->new({
        targetingDimension => AUDIENCE,
        bidOnly            => "true"
      });
    push @{$targeting_setting->{targetRestrictions}}, $new_restriction;
  }
}
      

curl

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

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.V25.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: GoogleAdsClient,
    customer_id: str,
    ad_group_id: str,
    targeting_setting: TargetingSetting,
) -> None:
    """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: AdGroupServiceClient = client.get_service(
        "AdGroupService"
    )

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

    # Populate the ad group object with the updated targeting setting.
    ad_group: AdGroup = 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: MutateAdGroupsResponse = (
        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::V25::Resources::AdGroup->new({
      resourceName =>
        Google::Ads::GoogleAds::V25::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::V25::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};
}
      

curl

कैंपेन के लिए, bid_only फ़ील्ड सेट करने की प्रोसेस भी लगभग एक जैसी होती है.

आगे क्या करना है

  • ज़रूरी शर्तों से जुड़ी गाइड में, ज़रूरी शर्तों के काम करने वाले टाइप एक्सप्लोर करें.