他のアセットとは異なり、住所アセットはアセットセットを作成した後に Google Ads API によって自動的に作成されます。まず、住所同期アセットセットを作成して顧客に関連付けます。次に、キャンペーンまたは広告グループのアセットセットで住所アセットのサブセットを選択する必要がある場合は、地域グループ アセットセットを作成してキャンペーンまたは広告グループに関連付けます。
住所同期アセットセットを作成して顧客に関連付ける
住所同期アセットセットを作成する
- 新しい
AssetSetを作成します。typeをLOCATION_SYNCに設定します。location_setを新しいLocationSetに設定します。
新しい
LocationSetで、- ユースケースに基づいて
location_ownership_typeを設定します。- ビジネスの拠点を所有している場合は、
BUSINESS_OWNERに設定します。 - ビジネスの拠点を所有していないが、そこで商品を販売している場合は、
AFFILIATEそこに設定します。
- ビジネスの拠点を所有している場合は、
ユースケースに基づいて
sourceoneof フィールドを設定します。Google ビジネス プロフィール アカウントの ビジネス情報と同期する場合は、
business_profile_location_setを設定します。Google Ads を Google ビジネス プロフィール アカウントにリンクする
BusinessProfileLocationSetを作成する場合は、http_authorization_tokenフィールドに OAuth 2.0 アクセス トークンを指定する必要があります。このトークンは、指定した Google ビジネス プロフィールから Google 広告がビジネス情報にアクセスすることを許可していることの証明となります。トークンは次の要件を満たしている必要があります。
BusinessProfileLocationSetのemail_addressフィールドに指定されたメールアドレスの Google アカウント(ユーザー アカウントまたはサービス アカウント)に対して生成されている必要があります。- このアカウントには、Google ビジネス プロフィール内の店舗拠点を読み取るための十分な権限が必要です。
- OAuth 2.0 トークンは、
https://www.googleapis.com/auth/business.manageスコープで取得する必要があります。
OAuth 2.0 アクセス トークンを生成する手順について詳しくは、 OAuth 2.0 を使用した Google API へのアクセスをご覧ください。
指定したチェーン ID のビジネス情報と同期する場合は、
chain_location_setを設定します。
- ユースケースに基づいて
上記の手順を完了すると、`AssetSetAssetService` を使用して手動で追加する場合と同様に、Google Ads API によって住所
アセット が生成され、作成した住所同期アセットセットに追加されます。静的地域
グループ アセットセットに手動で追加する場合を除き、操作する必要はありません。
顧客に対して有効な住所同期アセットセット
(statusが
ENABLED)は
1 つのみ存在できます。別のタイプの住所同期アセットセットを作成する必要がある場合は、まず既存のアセットセットを削除してください。
住所同期アセットセットを顧客に関連付ける
CustomerAssetSetService.MutateCustomerAssetSets
を使用して、前のセクションで作成した住所同期アセットセットを顧客に関連付けます。
(省略可)地域グループ アセットセットを作成してキャンペーンまたは広告グループに関連付ける
地域グループ アセットセットは、住所アセットのサブセットを選択する必要がある場合にのみ必要です。これは、キャンペーンと広告グループが顧客レベルから住所アセットを継承するためです。
地域グループ アセットセットには、住所同期 アセットセットの住所アセットのサブセットが含まれます。Google ビジネス プロフィールの機能(ラベルによるフィルタなど)やチェーン ID、チェーンのビジネス情報を活用して、地域グループ アセットセットを動的に作成できます。また、地域グループ アセットセットを静的に作成することもできます。
- 地域グループ アセットセットを作成します。地域グループ アセットセットは、動的 または静的 にできます。
- 必要に応じて、 を使用してキャンペーンに、 を使用して広告グループにアセットセットを関連付けます。
- (省略可)以前に生成したアセットを、新しく作成した静的 地域グループ アセットセットに追加します。
1 つの顧客に対して、複数の動的または静的地域グループ アセットセットを作成できます。
地域グループ アセットセットを作成する
新しい AssetSet を作成し、
location_group_parent_asset_set_id を、以前に作成した
住所同期アセットセットの 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 を住所同期アセットセットの作成時に設定した場合、動的地域グループ アセットセットを作成することはできません。これは、プレイス 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;
}
}