लोकेशन एसेट

अन्य ऐसेट के उलट, लोकेशन ऐसेट, ऐसेट सेट बनाने के बाद Google Ads API से अपने-आप जनरेट होती हैं. सबसे पहले, लोकेशन सिंक करने वाला ऐसेट सेट बनाएं और उसे ग्राहक से जोड़ें. इसके बाद, अगर आपको किसी कैंपेन या विज्ञापन ग्रुप के लिए, ऐसेट सेट में मौजूद लोकेशन ऐसेट का सबसेट चुनना है, तो लोकेशन ग्रुप वाला ऐसेट सेट बनाएं और उसे कैंपेन या विज्ञापन ग्रुप से जोड़ें.

लोकेशन सिंक करने वाला ऐसेट सेट बनाना और उसे ग्राहक से जोड़ना

  1. लोकेशन सिंक करने वाला ऐसेट सेट बनाएं.
  2. इसे CustomerAssetSetService का इस्तेमाल करके किसी ग्राहक से जोड़ें.

लोकेशन सिंक करने वाला ऐसेट सेट बनाना

  1. नया AssetSet बनाएं.
    1. type को LOCATION_SYNC पर सेट करें.
    2. location_set को नए LocationSet पर सेट करें.
  2. नए LocationSet में,

    1. अपने इस्तेमाल के हिसाब से, location_ownership_type सेट करें:
      • अगर कारोबार की जगह आपकी है, तो इसे BUSINESS_OWNER पर सेट करें.
      • अगर कारोबार की जगह आपकी नहीं है, लेकिन वहां आपके प्रॉडक्ट बेचे जाते हैं, तो इसे AFFILIATE पर सेट करें.
    2. अपने इस्तेमाल के हिसाब से, source oneof फ़ील्ड सेट करें:

      • अगर आपको अपने Google Business Profile खाते में मौजूद जगहों के साथ सिंक करना है, तो business_profile_location_set सेट करें.

        Google Ads को Google Business Profile खाते से लिंक करने के लिए, BusinessProfileLocationSet बनाते समय, आपको http_authorization_token फ़ील्ड में OAuth 2.0 ऐक्सेस टोकन देना होगा. यह टोकन इस बात का सबूत है कि आपने Google Ads को, तय किए गए Google Business Profile से लोकेशन डेटा ऐक्सेस करने की अनुमति दी है.

        टोकन के लिए ये ज़रूरी शर्तें पूरी होनी चाहिए:

        • इसे उस Google खाते (उपयोगकर्ता या सेवा खाता) के लिए जनरेट किया जाना चाहिए जिसका ईमेल पता, BusinessProfileLocationSet के email_address फ़ील्ड में दिया गया है.
        • इस खाते के पास, Google Business Profile में मौजूद कारोबार की जगहों को पढ़ने की ज़रूरी अनुमतियां होनी चाहिए.
        • OAuth 2.0 टोकन, https://www.googleapis.com/auth/business.manage स्कोप के साथ हासिल किया जाना चाहिए.

        OAuth 2.0 ऐक्सेस टोकन जनरेट करने के तरीके के बारे में ज़्यादा जानने के लिए, OAuth 2.0 का इस्तेमाल करके Google API को ऐक्सेस करना लेख पढ़ें.

      • अगर आपको तय की गई चेन आईडी में मौजूद जगहों के साथ सिंक करना है, तो chain_location_set सेट करें.

      • अगर आपको प्लेस आईडी का इस्तेमाल करके, मैन्युअल तरीके से जगहें जोड़नी हैं, तो maps_location_set सेट करें.

इन चरणों को पूरा करने के बाद, Google Ads API लोकेशन ऐसेट जनरेट करता है और उन्हें आपके लिए, बनाए गए लोकेशन सिंक करने वाले ऐसेट सेट में जोड़ता है. ठीक उसी तरह जैसे AssetSetAssetService का इस्तेमाल करके, मैन्युअल तरीके से ऐसा किया जाता है. अगर आपको उन्हें स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट में मैन्युअल तरीके से जोड़ना है, तो ही उनमें बदलाव करने की ज़रूरत होती है.

किसी ग्राहक के लिए, सिर्फ़ एक चालू लोकेशन सिंक करने वाला ऐसेट सेट (status की ENABLED) मौजूद हो सकता है. अगर आपको किसी दूसरे टाइप का लोकेशन सिंक करने वाला ऐसेट सेट बनाना है, तो पहले मौजूदा सेट को हटाएं.

लोकेशन सिंक करने वाले ऐसेट सेट को किसी ग्राहक से जोड़ना

पिछले सेक्शन में मौजूद लोकेशन सिंक करने वाले ऐसेट सेट को अपने ग्राहक से जोड़ने के लिए, CustomerAssetSetService.MutateCustomerAssetSets का इस्तेमाल करें.

(ज़रूरी नहीं) लोकेशन ग्रुप वाला ऐसेट सेट बनाना और उसे किसी कैंपेन या विज्ञापन ग्रुप से जोड़ना

लोकेशन ग्रुप वाला ऐसेट सेट सिर्फ़ तब ज़रूरी होता है, जब आपको लोकेशन ऐसेट का सबसेट चुनना हो. ऐसा इसलिए है, क्योंकि कैंपेन और विज्ञापन ग्रुप, ग्राहक लेवल से लोकेशन ऐसेट इनहेरिट करते हैं.

लोकेशन ग्रुप वाले ऐसेट सेट में, लोकेशन सिंक करने वाले ऐसेट सेट की लोकेशन ऐसेट का सबसेट होता है. Google Business Profile की कुछ सुविधाओं (जैसे, लेबल के हिसाब से फ़िल्टर करना) या चेन आईडी और चेन लोकेशन का इस्तेमाल करके, डाइनैमिक तरीके से लोकेशन ग्रुप वाला ऐसेट सेट बनाया जा सकता है. इसके अलावा, स्टैटिक तरीके से भी लोकेशन ग्रुप वाला ऐसेट सेट बनाया जा सकता है.

  1. लोकेशन ग्रुप वाला ऐसेट सेट बनाएं. लोकेशन ग्रुप वाला ऐसेट सेट डाइनैमिक या स्टैटिक हो सकता है.
  2. अपनी ज़रूरत के हिसाब से, ऐसेट सेट को किसी कैंपेन या विज्ञापन ग्रुप से जोड़ें.
  3. (ज़रूरी नहीं) पहले से जनरेट की गई ऐसेट को, नए बनाए गए स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट में जोड़ें.

किसी ग्राहक के लिए, डाइनैमिक या स्टैटिक लोकेशन ग्रुप वाले कई ऐसेट सेट बनाए जा सकते हैं.

लोकेशन ग्रुप वाला ऐसेट सेट बनाना

नया AssetSet बनाएं और सेट location_group_parent_asset_set_id को, पहले बनाए गए लोकेशन सिंक करने वाले ऐसेट सेट की आईडी पर सेट करें.

इसके बाद, कुछ फ़ील्ड सेट करें. यह इस बात पर निर्भर करता है कि आपको डाइनैमिक या स्टैटिक लोकेशन ग्रुप वाला ऐसेट सेट बनाना है.

डाइनैमिक ऐसेट सेट

LocationSet में सेट किए गए फ़ील्ड के हिसाब से, इन नियमों के मुताबिक फ़ील्ड सेट करें:

अगर आपने यह फ़ील्ड सेट किया है तो टाइप को इस पर सेट करें और इस फ़ील्ड को asset_set_source oneof फ़ील्ड के तौर पर सेट करें
business_profile_location_set BUSINESS_PROFILE_DYNAMIC_LOCATION_GROUP business_profile_location_group
chain_location_set CHAIN_DYNAMIC_LOCATION_GROUP chain_location_group

अगर आपने maps_location_set सेट किया है, जब लोकेशन सिंक करने वाला ऐसेट सेट बनाया जा रहा है, तो डाइनैमिक लोकेशन ग्रुप वाला ऐसेट सेट नहीं बनाया जा सकेगा. ऐसा इसलिए है, क्योंकि आपने प्लेस आईडी का इस्तेमाल करके, मैन्युअल तरीके से जगहें जोड़ी हैं. साथ ही, इस तरह की जगहों के लिए फ़िल्टर करने की कोई सुविधा उपलब्ध नहीं है.

स्टैटिक ऐसेट सेट

type को STATIC_LOCATION_GROUP पर सेट करें. लोकेशन सिंक करने वाले किसी भी टाइप के ऐसेट सेट के लिए, स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट बनाए जा सकते हैं. इससे कोई फ़र्क़ नहीं पड़ता कि आपने LocationSet में कौनसे फ़ील्ड (business_profile_location_set, chain_location_set, या maps_location_set) सेट किए हैं.

स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट के लिए, आपको जनरेट की गई लोकेशन ऐसेट को, लोकेशन ग्रुप वाले ऐसेट सेट में मैन्युअल तरीके से जोड़ना होगा.

ऐसेट सेट को किसी कैंपेन या विज्ञापन ग्रुप से जोड़ना

लोकेशन ग्रुप वाले ऐसेट सेट को अपने कैंपेन से जोड़ने के लिए, CampaignAssetSetService.MutateCampaignAssetSets का इस्तेमाल करें.

इसके अलावा, अगर आपको लोकेशन ग्रुप वाले ऐसेट सेट को किसी विज्ञापन ग्रुप से जोड़ना है, तो AdGroupAssetSetService.MutateAdGroupAssetSets का इस्तेमाल करें.

(ज़रूरी नहीं) लोकेशन ऐसेट को स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट में जोड़ना

यह चरण सिर्फ़ तब ज़रूरी है, जब आपने पहले स्टैटिक लोकेशन ग्रुप वाला ऐसेट सेट बनाया हो.

  1. पहले बनाए गए लोकेशन सिंक करने वाले ऐसेट सेट के लिए, अपने-आप जनरेट हुई ऐसेट के संसाधन के नाम फ़ेच करने के लिए, asset_set_asset रिपोर्ट का इस्तेमाल करें. सिर्फ़ वे ऐसेट पाने के लिए फ़िल्टर करने की सुविधा का इस्तेमाल करें जो आपको चाहिए.
  2. उन्हें स्टैटिक लोकेशन ग्रुप वाले ऐसेट सेट में जोड़ें.AssetSetAssetService.MutateAssetSetAssets

Business Profile के लोकेशन आईडी मैनेज करना

जब business_profile_location_set का इस्तेमाल किया जाता है और listing_id_filters पर फ़िल्टर किया जाता है, तो हो सकता है कि इन फ़िल्टर को Business Profile की वेबसाइट या एपीआई से वापस पाया गया हो. ऐसे में, इन न्यूमेरिक वैल्यू को uint64 टाइप से int64 टाइप में बदलना ज़रूरी हो सकता है. अगर आपका कोड, रनटाइम से जुड़ी गड़बड़ी जनरेट करता है जिसमें बताया जाता है कि आपका Business Profile का जगह का आईडी, listing_id_filters[] के दोहराए गए फ़ील्ड में जोड़ने पर, रेंज से बाहर है, तो आपको इसे इनमें से किसी एक उदाहरण का इस्तेमाल करके बदलना होगा:

Java

/**
* Converts the business profile location ID to the format expected by the
* DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
* The business profile location ID is an unsigned 64-bit integer, while the
* listing_id_filters[] field expects signed 64-bit integers. This means that
* for business profile location IDs that are out of range, we must perform the
* two's complement to convert it into a signed int.
 *
 * @param businessProfileLocationId The ID of a Business Profile location ID.
 * @return a Business Profile location ID as a signed 64-bit integer (long).
 */
public static long convertBusinessProfileLocationId(String businessProfileLocationId) {
    return Long.parseUnsignedLong(businessProfileLocationId);
}

C#

/// <summary>
/// Converts the business profile location ID to the format expected by the
/// DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
/// The business profile location ID is an unsigned 64-bit integer, while the
/// listing_id_filters[] field expects signed 64-bit integers. This means that
/// for business profile location IDs that are out of range, we must perform the
/// two's complement to convert it into a signed int.
/// </summary>
/// <param name="businessProfileLocationId">The ID of a Business Profile location.</param>
/// <returns>The converted business location ID in signed 64 bit.</returns>
public long ConvertBusinessProfileLocationId(ulong businessProfileLocationId)
{
  return unchecked((long)businessProfileLocationId);
}

PHP

/**
* Converts a business profile location ID to a signed 64 bit integer.
*
* Converts the business profile location ID to the format expected by the
* DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
* The business profile location ID is an unsigned 64-bit integer, while the
* listing_id_filters[] field expects signed 64-bit integers. This means that
* for business profile location IDs that are out of range, we must perform the
* two's complement to convert it into a signed int.
*
* @param string $businessProfileLocationId the ID of a Business Profile location
* @return int the converted business location ID in signed 64 bit
*/
public static function convertBusinessProfileLocationId(string $businessProfileLocationId): int
{
    $unsignedMax = '18446744073709551615'; // 2^64 - 1
    $signedMax = '9223372036854775807'; // 2^63 - 1

    // Check if the business profile location ID is within 64 bit range.
    // If not, throw an error.
    if (bccomp($businessProfileLocationId, '0') < 0 || bccomp($businessProfileLocationId, $unsignedMax) > 0) {
        throw new InvalidArgumentException(
            'The given business profile location id is outside of the range for a 64 bit integer.'
        );
    }

    // Check if the business profile location ID is in signed 64 bit range.
    // If it's not, convert it to its two's complement.
    if (bccomp($businessProfileLocationId, $signedMax) > 0) {
        // Two's complement: ID - 2^64
        return (int) bcsub($businessProfileLocationId, '18446744073709551616');
    }

    return (int) $businessProfileLocationId;
}

Python

import ctypes

def convert_business_profile_location_id(business_profile_location_id):
    """Converts a business profile location ID to a signed 64 bit integer.

    Converts the business profile location ID to the format expected by the
    DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
    The business profile location ID is an unsigned 64-bit integer, while the
    listing_id_filters[] field expects signed 64-bit integers. This means that
    for business profile location IDs that are out of range, we must perform the
    two's complement to convert it into a signed int.

    Args:
        business_profile_location_id: the ID of a Business Profile location ID.

    Returns:
        a Business Profile location ID as a signed 64 bit integer.
    """
    # Check if the business profile location ID is within 64 bit range.
    # If not, throw an error.
    if business_profile_location_id >= 2 ** 64:
        raise ValueError(
            "The given business profile location id is outside of the range for a 64 bit integer."
        )
    # Check if the business profile location ID is in signed 64 bit range.
    # If it's not, convert it to its two's complement.
    elif business_profile_location_id >= 2 ** 63:
        return ctypes.c_int64(business_profile_location_id).value
    else:
        return business_profile_location_id

Ruby

# Converts the business profile location ID to the format expected by the
# DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
# The business profile location ID is an unsigned 64-bit integer, while the
# listing_id_filters[] field expects signed 64-bit integers. This means that
# for business profile location IDs that are out of range, we must perform the
# two's complement to convert it into a signed int.
# Since Ruby supports arbitrary precision numbers, we have to calculate it
# manually.
LONG_MAX = 2 ** 63
ULONG_MAX = LONG_MAX * 2
def convert_business_profile_location_id(business_profile_location_id)
  # Check if the business profile location ID is within 64 bit range.
  # If not, throw an error.
  if business_profile_location_id >= 2 ** 64
    raise "The given business profile location id is outside of the range for a 64 bit integer."
  # Check if the business profile location ID is in signed 64 bit range.
  # If it's not, convert it to its two's complement.
  elseif business_profile_location_id >= 2**63
    -1 * (ULONG_MAX - business_profile_location_id)
  else
    business_profile_location_id
  end
end

Perl

use bigint;

# Converts the business profile location ID to the format expected by the
# DynamicBusinessProfileLocationGroupFilter.listing_id_filters[] repeated field.
# The business profile location ID is an unsigned 64-bit integer, while the
# listing_id_filters[] field expects signed 64-bit integers. This means that
# for business profile location IDs that are out of range, we must perform the
# two's complement to convert it into a signed int.
sub convert_business_profile_location_id {
  my ($business_profile_location_id) = @_;

  # Check if the business profile location ID is within 64 bit range.
  # If not, throw an error.
  if ($business_profile_location_id >= 2**64) {
    die "The given business profile location id is outside of the range for a 64 bit integer";
  # Check if the business profile location ID is in signed 64 bit range.
  # If it's not, convert it to its two's complement.
  } elseif ($business_profile_location_id >= 2**63) {
    return -1 * (2**64 - $business_profile_location_id);
  } else {
    return $business_profile_location_id;
  }
}