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

على عكس مواد العرض الأخرى، يتم إنشاء مواد عرض المواقع الجغرافية تلقائيًا من خلال 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.

        عند إنشاء BusinessProfileLocationSet لربط "إعلانات Google" بحساب على "الملف التجاري على Google"، يجب تقديم رمز دخول OAuth 2.0 في الحقل http_authorization_token. يعمل هذا الرمز المميّز كدليل على أنّك تسمح لـ "إعلانات Google" بالوصول إلى بيانات الموقع الجغرافي من "الملف التجاري على Google" المحدّد.

        يجب أن يستوفي الرمز المميز المتطلبات التالية:

        • يجب إنشاء هذا الرمز لحساب Google (مستخدم أو حساب خدمة) الذي تم تقديم عنوان بريده الإلكتروني في الحقل email_address من BusinessProfileLocationSet.
        • يجب أن يتضمّن هذا الحساب أذونات كافية لقراءة المواقع الجغرافية للنشاط التجاري ضمن "الملف التجاري على Google".
        • يجب الحصول على رمز OAuth 2.0 المميز باستخدام النطاق https://www.googleapis.com/auth/business.manage.

        للحصول على تعليمات مفصّلة حول كيفية إنشاء رمز مميّز للوصول إلى OAuth 2.0، يُرجى الرجوع إلى استخدام بروتوكول OAuth 2.0 للدخول إلى Google APIs.

      • اضبط 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. إذا كان الرمز البرمجي يعرض خطأ وقت التشغيل يشير إلى أنّ رقم تعريف الموقع الجغرافي الخاص بملفك التجاري خارج النطاق عند إضافته إلى الحقل المتكرّر listing_id_filters[]، من المحتمل أنّك بحاجة إلى تحويله باستخدام أيّ من الأمثلة التالية:

جافا

/**
 * 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 < 0 or 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 < 0 || 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.
  elsif 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 < 0 || $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.
  } elsif ($business_profile_location_id >= 2**63) {
    return -1 * (2**64 - $business_profile_location_id);
  } else {
    return $business_profile_location_id;
  }
}