Aset lokasi

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

Buat set aset sinkronisasi lokasi dan lampirkan ke pelanggan

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

Membuat set 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 adalah pemilik 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 di akun Google Profil Bisnis Anda.
      • Tetapkan chain_location_set jika Anda ingin menyinkronkan dengan lokasi di ID jaringan bisnis 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 set 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 set aset grup lokasi statis.

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

Menghubungkan set aset sinkronisasi lokasi ke pelanggan

Gunakan CustomerAssetSetService.MutateCustomerAssetSets untuk melampirkan set aset sinkronisasi lokasi yang ditetapkan di bagian sebelumnya ke pelanggan Anda.

(Opsional) Buat set aset grup lokasi dan lampirkan ke kampanye atau grup iklan

Kumpulan aset grup lokasi hanya diperlukan jika Anda perlu memilih subset aset lokasi. Hal ini disebabkan oleh kampanye dan grup iklan yang mewarisi aset lokasi dari tingkat pelanggan.

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

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

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

Membuat set aset grup lokasi

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

Kemudian, tetapkan beberapa kolom berdasarkan apakah Anda ingin membuat set 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 type ke 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 set aset sinkronisasi lokasi, Anda tidak akan dapat membuat set aset grup lokasi dinamis. Hal ini karena Anda telah menambahkan lokasi secara manual menurut 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 set aset grup lokasi statis untuk semua jenis set aset sinkronisasi lokasi, terlepas dari kolom (business_profile_location_set, chain_location_set, atau maps_location_set) yang Anda tetapkan di LocationSet.

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

Lampirkan set 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) Tambahkan aset lokasi ke set 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 ke set aset grup lokasi statis menggunakan AssetSetAssetService.MutateAssetSetAssets.

Mengelola ID lokasi Profil Bisnis

Saat Anda menggunakan business_profile_location_set dan memfilter listing_id_filters yang diambil dari situs atau API Profil Bisnis, Anda mungkin perlu mengonversi nilai numerik ini dari jenis uint64 ke int64. Jika kode Anda menghasilkan error runtime bahwa ID lokasi Profil Bisnis Anda berada di luar rentang saat menambahkannya ke kolom berulang listingan_id_filters[], maka 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;
  }
}