लोकेशन एसेट

अन्य ऐसेट के उलट, ऐसेट सेट बनाने के बाद 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 सेट करें.
      • अगर आपको तय किए गए चेन आईडी में मौजूद जगहों के साथ सिंक करना है, तो 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 में जो फ़ील्ड सेट किया है उसके हिसाब से, यहां दिए गए नियम के आधार पर फ़ील्ड सेट करें:

अगर आपने यह फ़ील्ड सेट किया है इसके बाद, type को इस फ़ील्ड को 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 की वेबसाइट या एपीआई से हासिल किए गए listing_id_filters पर फ़िल्टर करने के लिए, business_profile_location_set का इस्तेमाल करने पर, इन संख्यात्मक वैल्यू को uint64 से int64 में बदलना ज़रूरी हो सकता है. अगर listing_id_filters[] repeated फ़ील्ड में कोड जोड़ने पर, आपको रनटाइम गड़बड़ी दिखती है और Business Profile का लोकेशन आईडी रेंज से बाहर है, तो आपको इसे इनमें से किसी उदाहरण का इस्तेमाल करके बदलना होगा:

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