Aset lokasi

Tidak seperti aset lainnya, aset lokasi dibuat secara otomatis oleh Google Ads API setelah Anda membuat kumpulan aset. Pertama, buat kumpulan aset sinkronisasi lokasi dan lampirkan ke pelanggan. Kemudian, jika Anda perlu memilih subkumpulan aset lokasi dalam kumpulan aset untuk kampanye atau grup iklan, buat kumpulan aset grup lokasi dan lampirkan ke kampanye atau grup iklan.

Membuat kumpulan aset sinkronisasi lokasi dan melampirkannya ke pelanggan

  1. Buat kumpulan aset sinkronisasi lokasi.
  2. Lampirkan ke pelanggan menggunakan CustomerAssetSetService.

Membuat kumpulan aset sinkronisasi lokasi

  1. Buat AssetSet baru.
    1. Tetapkan type ke LOCATION_SYNC.
    2. Tetapkan location_set ke LocationSet baru.
  2. Di LocationSet baru,

    1. Tetapkan location_ownership_type berdasarkan kasus penggunaan Anda:
      • Tetapkan ke BUSINESS_OWNER jika Anda memiliki lokasi bisnis.
      • Tetapkan ke AFFILIATE jika Anda tidak memiliki lokasi bisnis, tetapi menjual produk Anda di sana.
    2. Tetapkan kolom oneof source berdasarkan kasus penggunaan Anda:

      • Tetapkan business_profile_location_set jika Anda ingin menyinkronkan dengan lokasi Anda di akun Google Profil Bisnis Anda.

        Saat Anda membuat BusinessProfileLocationSet untuk menautkan Google Ads dengan akun Google Profil Bisnis, Anda harus memberikan token akses OAuth 2.0 di kolom http_authorization_token. Token ini berfungsi sebagai bukti bahwa Anda mengizinkan Google Ads mengakses data lokasi dari Google Profil Bisnis yang ditentukan.

        Token harus memenuhi persyaratan berikut:

        • Token harus dibuat untuk Akun Google (pengguna atau akun layanan) yang alamat emailnya diberikan di kolom email_address dari BusinessProfileLocationSet.
        • Akun ini harus memiliki izin yang memadai untuk membaca lokasi bisnis dalam Google Profil Bisnis.
        • Token OAuth 2.0 harus diperoleh dengan cakupan https://www.googleapis.com/auth/business.manage.

        Untuk mengetahui petunjuk mendetail tentang cara membuat token akses OAuth 2.0, lihat Menggunakan OAuth 2.0 untuk Mengakses Google API.

      • Tetapkan chain_location_set jika Anda ingin menyinkronkan dengan lokasi dalam ID jaringan yang ditentukan.

      • Tetapkan maps_location_set jika Anda ingin menambahkan lokasi secara manual menggunakan ID Tempat.

Setelah Anda menyelesaikan langkah-langkah ini, Google Ads API akan membuat aset lokasi dan menambahkannya ke kumpulan aset sinkronisasi lokasi yang dibuat untuk Anda, mirip dengan saat Anda melakukannya secara manual menggunakan AssetSetAssetService. Anda tidak perlu memanipulasinya kecuali jika Anda ingin menambahkannya secara manual ke kumpulan aset grup lokasi statis.

Hanya satu kumpulan aset sinkronisasi lokasi aktif dengan (status dari ENABLED) yang dapat ada untuk pelanggan. Jika Anda perlu membuat jenis kumpulan aset sinkronisasi lokasi yang berbeda, hapus kumpulan aset yang ada terlebih dahulu.

Melampirkan kumpulan aset sinkronisasi lokasi ke pelanggan

Gunakan CustomerAssetSetService.MutateCustomerAssetSets untuk melampirkan kumpulan aset sinkronisasi lokasi di bagian sebelumnya ke pelanggan Anda.

(Opsional) Membuat kumpulan aset grup lokasi dan melampirkannya ke kampanye atau grup iklan

Kumpulan aset grup lokasi hanya diperlukan jika Anda perlu memilih subkumpulan aset lokasi. Hal ini karena kampanye dan grup iklan mewarisi aset lokasi dari tingkat pelanggan.

Kumpulan aset grup lokasi berisi subkumpulan aset lokasi dari kumpulan aset sinkronisasi lokasi. Anda dapat membuat kumpulan aset grup lokasi secara dinamis dengan memanfaatkan beberapa fitur Google Profil Bisnis (seperti memfilter menurut label) atau ID jaringan dan lokasi jaringan. Atau, Anda dapat membuat kumpulan aset grup lokasi secara statis.

  1. Buat kumpulan aset grup lokasi. Kumpulan aset grup lokasi dapat bersifat dinamis atau statis.
  2. Lampirkan kumpulan aset ke kampanye menggunakan atau ke grup iklan, bergantung pada kebutuhan Anda.
  3. (Opsional) Tambahkan aset yang sebelumnya dibuat ke kumpulan aset grup lokasi statis yang baru dibuat.

Untuk pelanggan tertentu, Anda dapat membuat beberapa kumpulan aset grup lokasi dinamis atau statis.

Membuat kumpulan aset grup lokasi

Buat AssetSet baru dan tetapkan location_group_parent_asset_set_id ke ID kumpulan aset sinkronisasi lokasi yang dibuat sebelumnya.

Kemudian, tetapkan beberapa kolom berdasarkan apakah Anda ingin membuat kumpulan aset grup lokasi dinamis atau statis.

Kumpulan aset dinamis

Bergantung pada kolom yang Anda tetapkan di LocationSet, tetapkan kolom berdasarkan aturan berikut:

Jika Anda menetapkan kolom berikut Kemudian tetapkan jenis ke Dan tetapkan kolom ini sebagai kolom oneof asset_set_source
business_profile_location_set BUSINESS_PROFILE_DYNAMIC_LOCATION_GROUP business_profile_location_group
chain_location_set CHAIN_DYNAMIC_LOCATION_GROUP chain_location_group

Jika Anda menetapkan maps_location_set saat membuat kumpulan aset sinkronisasi lokasi set, Anda tidak akan dapat membuat kumpulan aset grup lokasi dinamis. Hal ini karena Anda telah menambahkan lokasi secara manual berdasarkan ID Tempat dan tidak ada fitur pemfilteran yang dapat Anda gunakan untuk jenis lokasi ini.

Kumpulan aset statis

Tetapkan type ke STATIC_LOCATION_GROUP. Anda dapat membuat kumpulan aset grup lokasi statis untuk semua jenis kumpulan aset sinkronisasi lokasi, apa pun kolom (business_profile_location_set, chain_location_set, atau maps_location_set) yang Anda tetapkan di LocationSet.

Untuk statis kumpulan aset grup lokasi, Anda harus menambahkan aset lokasi yang dibuat secara manual ke kumpulan aset grup lokasi sets.

Melampirkan kumpulan aset ke kampanye atau grup iklan

Gunakan CampaignAssetSetService.MutateCampaignAssetSets untuk melampirkan kumpulan aset grup lokasi ke kampanye Anda.

Atau, gunakan AdGroupAssetSetService.MutateAdGroupAssetSets jika Anda ingin melampirkan kumpulan aset grup lokasi ke grup iklan.

(Opsional) Menambahkan aset lokasi ke kumpulan aset grup lokasi statis

Langkah ini hanya diperlukan jika Anda membuat kumpulan aset grup lokasi statis sebelumnya.

  1. Gunakan laporan asset_set_asset untuk mengambil nama resource aset yang dibuat secara otomatis untuk kumpulan aset sinkronisasi lokasi yang dibuat sebelumnya. Gunakan pemfilteran untuk mengambil hanya aset yang Anda inginkan.
  2. Tambahkan aset ke kumpulan aset grup lokasi statis menggunakan AssetSetAssetService.MutateAssetSetAssets.

Mengelola ID lokasi Google Profil Bisnis

Saat Anda menggunakan business_profile_location_set dan memfilter listing_id_filters yang diambil dari situs atau API Google Profil Bisnis, Anda mungkin perlu mengonversi nilai numerik ini dari jenis uint64 ke int64. Jika kode Anda menghasilkan error runtime bahwa ID lokasi Google Profil Bisnis Anda berada di luar rentang saat menambahkannya ke kolom berulang listing_id_filters[], Anda mungkin perlu mengonversinya menggunakan salah satu contoh berikut:

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