مواد عرض المواقع الجغرافية

على عكس مواد العرض الأخرى، يتم إنشاء مواد عرض المواقع الجغرافية تلقائيًا من خلال 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 استنادًا إلى حالة الاستخدام:
      • اضبط business_profile_location_set إذا كنت تريد المزامنة مع مواقعك الجغرافية في حسابك على الملف التجاري على Google.
      • اضبط chain_location_set إذا كنت تريد المزامنة مع المواقع الجغرافية التي تتضمّن أرقام تعريف سلاسل محدّدة.
      • اضبط maps_location_set إذا كنت تريد إضافة المواقع الجغرافية يدويًا باستخدام معرّفات الأماكن.

بعد إكمال هذه الخطوات، تنشئ Google Ads API مواد عرض خاصة بالموقع الجغرافي وتضيفها إلى مجموعة مواد العرض التي تم إنشاؤها لمزامنة الموقع الجغرافي، وذلك بشكل مشابه لما يحدث عند إجراء ذلك يدويًا باستخدام AssetSetAssetService. ليس عليك تعديلها إلا إذا أردت إضافتها يدويًا إلى مجموعات مواد عرض ثابتة خاصة بمجموعة مواقع جغرافية.

يمكن أن تتوفّر مجموعة واحدة فقط من مواد عرض مزامنة المواقع الجغرافية النشطة مع (status من ENABLED) لأحد العملاء. إذا كنت بحاجة إلى إنشاء مجموعة مواد عرض لمزامنة المواقع الجغرافية من نوع مختلف، عليك إزالة المجموعة الحالية أولاً.

ربط مجموعة مواد عرض مزامنة الموقع الجغرافي بعميل

استخدِم CustomerAssetSetService.MutateCustomerAssetSets لربط مجموعة مواد عرض مزامنة الموقع الجغرافي التي تم إعدادها في القسم السابق بعميلك.

(اختياري) إنشاء مجموعة مواد عرض خاصة بمجموعة مواقع جغرافية وإرفاقها بحملة أو مجموعة إعلانية

لا تكون مجموعة مواد عرض مجموعة المواقع الجغرافية ضرورية إلا إذا كنت بحاجة إلى اختيار مجموعة فرعية من مواد عرض المواقع الجغرافية. يعود ذلك إلى أنّ الحملات والمجموعات الإعلانية تكتسب مواد عرض المواقع الجغرافية من مستوى العميل.

تحتوي مجموعات مواد العرض الخاصة بمجموعات المواقع الجغرافية على مجموعة فرعية من مواد عرض المواقع الجغرافية الخاصة بمجموعة مواد العرض مزامنة المواقع الجغرافية. يمكنك إنشاء مجموعة مواد عرض لمجموعة مواقع جغرافية بشكل ديناميكي من خلال الاستفادة من بعض ميزات "الملف التجاري على Google" (مثل الفلترة حسب التصنيفات) أو أرقام تعريف السلسلة ومواقعها الجغرافية. بدلاً من ذلك، يمكنك إنشاء مجموعة مواد عرض ثابتة خاصة بمجموعة مواقع جغرافية.

  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. يمكنك إنشاء مجموعات مواد عرض ثابتة لمجموعات المواقع الجغرافية لأي نوع من مجموعات مواد العرض المتزامنة مع الموقع الجغرافي، بغض النظر عن الحقول (business_profile_location_set أو chain_location_set أو maps_location_set) التي تحدّدها في LocationSet.

بالنسبة إلى مجموعات مواد عرض المواقع الجغرافية الثابتة، عليك إضافة مواد عرض المواقع الجغرافية التي تم إنشاؤها يدويًا إلى مجموعات مواد عرض المواقع الجغرافية.

ربط مجموعة مواد العرض بحملة أو مجموعة إعلانية

استخدِم CampaignAssetSetService.MutateCampaignAssetSets لربط مجموعة مواد عرض الموقع الجغرافي بحملتك.

بدلاً من ذلك، استخدِم AdGroupAssetSetService.MutateAdGroupAssetSets إذا كنت تريد ربط مجموعة مواد عرض المواقع الجغرافية بمجموعة إعلانية بدلاً من ذلك.

(اختياري) أضِف مواد عرض المواقع الجغرافية إلى مجموعة مواد عرض مجموعة المواقع الجغرافية الثابتة.

هذه الخطوة مطلوبة فقط في حال إنشاء مجموعة مواد عرض لمجموعة مواقع جغرافية ثابتة سابقًا.

  1. استخدِم تقرير asset_set_asset لجلب أسماء الموارد الخاصة بمواد العرض التي تم إنشاؤها تلقائيًا لمجموعة مواد عرض مزامنة المواقع الجغرافية التي تم إنشاؤها سابقًا. استخدِم الفلترة لاسترداد مواد العرض التي تريدها فقط.
  2. أضِفها إلى مجموعة مواد عرض مجموعة المواقع الجغرافية الثابتة باستخدام AssetSetAssetService.MutateAssetSetAssets.

إدارة معرّفات المواقع الجغرافية للملفات التجارية

عند استخدام business_profile_location_set وتطبيق فلتر على listing_id_filters التي يتم استردادها من الموقع الإلكتروني أو واجهة برمجة التطبيقات الخاصة بـ "الملف التجاري"، قد يكون من الضروري تحويل هذه القيم الرقمية من النوع uint64 إلى int64. إذا كان الرمز يؤدي إلى حدوث خطأ في وقت التشغيل يشير إلى أنّ معرّف الموقع الجغرافي في "الملف التجاري على Google" خارج النطاق عند إضافته إلى الحقل المتكرّر 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;
  }
}