他のアセットとは異なり、住所アセットはアセットセットを作成した後に Google Ads API によって自動的に作成されます。まず、住所同期アセット セットを作成して、顧客に割り当てます。次に、キャンペーンまたは広告グループのアセットセットで住所アセットのサブセットを選択する必要がある場合は、住所グループ アセットセットを作成して、キャンペーンまたは広告グループに関連付けます。
住所同期アセット セットを作成して顧客に関連付ける
住所同期アセット セットを作成する
- 新しい
AssetSet
を作成します。type
をLOCATION_SYNC
に設定します。location_set
を新しいLocationSet
に設定します。
- 新しい
LocationSet
で、- ユースケースに基づいて
location_ownership_type
を設定します。- ビジネス拠点を所有している場合は、
BUSINESS_OWNER
に設定します。 - ビジネスの所在地を所有していないが、そこで商品を販売している場合は、
AFFILIATE
に設定します。
- ビジネス拠点を所有している場合は、
- ユースケースに基づいて
source
oneof フィールドを設定します。- Google ビジネス プロフィール アカウントの所在地と同期する場合は、
business_profile_location_set
を設定します。 - 指定したチェーン ID の拠点と同期する場合は、
chain_location_set
を設定します。 - プレイス ID を使用して手動で場所を追加する場合は、
maps_location_set
を設定します。
- Google ビジネス プロフィール アカウントの所在地と同期する場合は、
- ユースケースに基づいて
これらの手順を完了すると、Google 広告 API は地域情報アセットを生成し、作成した地域情報同期アセット セットに追加します。これは、AssetSetAssetService
を使用して手動で追加する場合と同様です。静的ロケーション グループ アセットセットに手動で追加する場合を除き、操作する必要はありません。
お客様に対して存在できる有効なロケーション同期アセット セットは 1 つのみです(ENABLED
の status
)。別のタイプの住所同期アセット セットを作成する必要がある場合は、まず既存のものを削除します。
位置情報同期アセット セットを顧客にリンクする
CustomerAssetSetService.MutateCustomerAssetSets
を使用して、前のセクションで設定した住所同期アセット セットを顧客に関連付けます。
(省略可)地域グループ アセット セットを作成してキャンペーンまたは広告グループに関連付ける
地域グループのアセット セットは、住所アセットのサブセットを選択する必要がある場合にのみ必要です。これは、キャンペーンと広告グループが顧客レベルから住所アセットを継承するためです。
ビジネス グループのアセット セットには、ビジネスの同期アセット セットのビジネス アセットのサブセットが含まれています。Google ビジネス プロフィールの機能(ラベルによるフィルタなど)やチェーン ID、チェーンのビジネス情報を活用して、地域グループのアセットセットを動的に作成できます。また、ロケーション グループのアセット セットを静的に作成することもできます。
- ビジネス グループのアセット セットを作成します。地域グループのアセット セットは、動的または静的にできます。
- 必要に応じて、アセットセットをキャンペーンまたは広告グループにリンクします。
- (省略可)以前に生成したアセットを、新しく作成した静的ロケーション グループのアセット セットに追加します。
お客様ごとに、複数の動的または静的なビジネス グループ アセットセットを作成できます。
地域グループのアセット セットを作成する
新しい AssetSet
を作成し、location_group_parent_asset_set_id
を以前に作成した住所同期アセット セットの 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
を設定すると、動的住所グループのアセット セットを作成できなくなります。これは、場所 ID で場所を手動で追加したため、このタイプの場所に使用できるフィルタリング機能がないためです。
静的アセットセット
type
を STATIC_LOCATION_GROUP
に設定します。LocationSet
で設定したフィールド(business_profile_location_set
、chain_location_set
、maps_location_set
)に関係なく、あらゆるタイプのロケーション同期アセットセットに対して静的ロケーション グループ アセットセットを作成できます。
静的な地域グループのアセット セットの場合は、生成された地域アセットを地域グループのアセット セットに手動で追加する必要があります。
アセットセットをキャンペーンまたは広告グループに関連付ける
CampaignAssetSetService.MutateCampaignAssetSets
を使用して、地域グループ アセットセットをキャンペーンに関連付けます。
代わりに、地域グループ アセット セットを広告グループに関連付ける場合は、AdGroupAssetSetService.MutateAdGroupAssetSets
を使用します。
(省略可)住所アセットを静的な地域グループのアセット セットに追加する
この手順は、以前に静的地域グループ アセット セットを作成した場合にのみ必要です。
asset_set_asset
レポートを使用して、以前に作成した位置情報同期アセット セット用に自動生成されたアセットのリソース名を取得します。フィルタリングを使用して、必要なアセットのみを取得します。AssetSetAssetService.MutateAssetSetAssets
を使用して、静的地域グループ アセットセットに追加します。
ビジネス プロフィールの地域 ID を管理する
business_profile_location_set
を使用して、ビジネス プロフィールのウェブサイトまたは API から取得した listing_id_filters
をフィルタする場合、これらの数値を uint64
型から int64
型に変換する必要があることがあります。listing_id_filters[] の繰り返しフィールドに追加するときに、ビジネス プロフィールの地域 ID が範囲外であるという実行時エラーがコードで生成される場合は、次のいずれかの例を使用して変換する必要があります。
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;
}
}