Im Gegensatz zu anderen Assets werden Standort-Assets automatisch von der Google Ads API erstellt, nachdem Sie eine Asset-Gruppe erstellt haben. Erstellen Sie zuerst eine Asset-Sammlung für die Standortsynchronisierung und hängen Sie sie an den Kunden an. Wenn Sie dann eine Teilmenge der Standort-Assets in der Asset-Sammlung für eine Kampagne oder Anzeigengruppe auswählen müssen, erstellen Sie ein Standortgruppen-Asset-Set und hängen Sie es an die Kampagne oder Anzeigengruppe an.
Asset-Sammlung für die Standortsynchronisierung erstellen und dem Kunden zuweisen
- Erstellen Sie eine Standortsynchronisierung-Asset-Sammlung.
- Mit
CustomerAssetSetServiceeinem Kunden zuordnen.
Asset-Sammlung für die Standortsynchronisierung erstellen
- Erstellen Sie einen neuen
AssetSet.- Setze
typeaufLOCATION_SYNC. - Legen Sie
location_setauf eine neueLocationSetfest.
- Setze
In der neuen
LocationSet- Legen Sie
location_ownership_typebasierend auf Ihrem Anwendungsfall fest:- Legen Sie den Wert auf
BUSINESS_OWNERfest, wenn Sie der Inhaber des Standorts sind. - Legen Sie den Wert auf
AFFILIATEfest, wenn Sie nicht Inhaber des Geschäftsstandorts sind, dort aber Ihre Produkte verkaufen.
- Legen Sie den Wert auf
Legen Sie das „oneof“-Feld
sourceentsprechend Ihrem Anwendungsfall fest:Legen Sie
business_profile_location_setfest, wenn Sie die Synchronisierung mit Ihren Standorten in Ihrem Google Unternehmensprofil-Konto vornehmen möchten.Wenn Sie ein
BusinessProfileLocationSeterstellen, um Google Ads mit einem Google Unternehmensprofil-Konto zu verknüpfen, müssen Sie ein OAuth 2.0-Zugriffstoken im Feldhttp_authorization_tokenangeben. Dieses Token dient als Nachweis dafür, dass Sie Google Ads autorisieren, auf die Standortdaten aus dem angegebenen Unternehmensprofil zuzugreifen.Das Token muss die folgenden Anforderungen erfüllen:
- Es muss für das Google-Konto (Nutzer- oder Dienstkonto) generiert werden, dessen E‑Mail-Adresse im Feld
email_addressderBusinessProfileLocationSetangegeben ist. - Dieses Konto muss ausreichende Berechtigungen haben, um die Unternehmensstandorte im Unternehmensprofil zu lesen.
- Das OAuth 2.0-Token muss mit dem Bereich
https://www.googleapis.com/auth/business.manageabgerufen werden.
Eine detaillierte Anleitung zum Generieren eines OAuth 2.0-Zugriffstokens finden Sie unter OAuth 2.0 für den Zugriff auf Google APIs verwenden.
- Es muss für das Google-Konto (Nutzer- oder Dienstkonto) generiert werden, dessen E‑Mail-Adresse im Feld
Legen Sie
chain_location_setfest, wenn Sie mit Standorten in angegebenen Ketten-IDs synchronisieren möchten.Legen Sie
maps_location_setfest, wenn Sie Standorte manuell mit Orts-IDs hinzufügen möchten.
- Legen Sie
Nachdem Sie diese Schritte ausgeführt haben, werden über die Google Ads API Standort-Assets generiert und der erstellten Asset-Sammlung für die Standortsynchronisierung hinzugefügt. Das ist vergleichbar mit dem manuellen Vorgehen über AssetSetAssetService. Sie müssen sie nicht bearbeiten, es sei denn, Sie möchten sie manuell einem Asset-Set für statische Standortgruppen hinzufügen.
Für einen Kunden kann nur eine aktive Asset-Sammlung für die Standortsynchronisierung mit status auf ENABLED festgelegt sein. Wenn Sie eine andere Art von Asset-Gruppe für die Standortsynchronisierung erstellen möchten, müssen Sie die vorhandene zuerst entfernen.
Asset-Sammlung für die Standortsynchronisierung an einen Kunden anhängen
Verwenden Sie CustomerAssetSetService.MutateCustomerAssetSets, um die im vorherigen Abschnitt festgelegte Asset-Sammlung für die Standortsynchronisierung an Ihren Kunden anzuhängen.
Optional: Asset-Sammlung für Standortgruppen erstellen und einer Kampagne oder Anzeigengruppe zuweisen
Ein Asset-Set vom Typ Standortgruppe ist nur erforderlich, wenn Sie eine Teilmenge von Standort-Assets auswählen müssen. Das liegt daran, dass Kampagnen und Anzeigengruppen Standort-Assets auf Kundenebene übernehmen.
Standortgruppen-Asset-Sammlungen enthalten eine Teilmenge der Standort-Assets der Asset-Sammlung Standortsynchronisierung. Sie können dynamisch eine Asset-Sammlung für Standortgruppen erstellen, indem Sie einige Funktionen von Google Unternehmensprofil nutzen, z. B. das Filtern nach Labels, oder Ketten-IDs und Kettenstandorte. Alternativ können Sie statisch eine Asset-Sammlung für Standortgruppen erstellen.
- Asset-Sammlung für Standortgruppe erstellen Die Asset-Sammlung für Standortgruppen kann dynamisch oder statisch sein.
- Hängen Sie die Asset-Sammlung an eine Kampagne oder Anzeigengruppe an.
- Optional: Fügen Sie die zuvor generierten Assets dem neu erstellten Asset-Set für statische Standorte hinzu.
Sie können für einen bestimmten Kunden mehrere dynamische oder statische Asset-Sets für Standortgruppen erstellen.
Asset-Sammlung für Standortgruppen erstellen
Erstellen Sie ein neues AssetSet und legen Sie location_group_parent_asset_set_id auf die ID der zuvor erstellten Asset-Sammlung für die Standortsynchronisierung fest.
Legen Sie dann einige Felder fest, je nachdem, ob Sie eine dynamische oder statische Asset-Sammlung für Standortgruppen erstellen möchten.
Dynamische Asset-Gruppen
Je nachdem, welches Feld Sie in LocationSet festlegen, müssen Sie die Felder gemäß der folgenden Regel festlegen:
| Wenn Sie das folgende Feld festlegen | Legen Sie dann type auf | Legen Sie dieses Feld als asset_set_source-oneof-Feld fest. |
|---|---|---|
business_profile_location_set |
BUSINESS_PROFILE_DYNAMIC_LOCATION_GROUP |
business_profile_location_group |
chain_location_set |
CHAIN_DYNAMIC_LOCATION_GROUP |
chain_location_group |
Wenn Sie maps_location_set beim Erstellen der Asset-Sammlung für die Standortsynchronisierung festlegen, können Sie keine dynamische Asset-Sammlung für Standortgruppen erstellen. Das liegt daran, dass Sie Standorte manuell über Orts-IDs hinzugefügt haben. Für diese Art von Standorten sind keine Filterfunktionen verfügbar.
Statische Asset-Sammlungen
Setzen Sie type auf
STATIC_LOCATION_GROUP.
Sie können statische Asset-Sets für Standortgruppen für alle Arten von Asset-Sets für die Standortsynchronisierung erstellen, unabhängig davon, welche Felder (business_profile_location_set, chain_location_set oder maps_location_set) Sie in LocationSet festlegen.
Bei statischen Standortgruppen-Asset-Sammlungen müssen Sie die generierten Standort-Assets manuell den Standortgruppen-Asset-Sammlungen hinzufügen.
Asset-Sammlung einer Kampagne oder Anzeigengruppe zuordnen
Verwenden Sie CampaignAssetSetService.MutateCampaignAssetSets, um die Asset-Sammlung für Standortgruppen an Ihre Kampagne anzuhängen.
Alternativ können Sie AdGroupAssetSetService.MutateAdGroupAssetSets verwenden, wenn Sie die Asset-Sammlung für Standortgruppen stattdessen einer Anzeigengruppe zuordnen möchten.
Optional: Standort-Assets zum Asset-Set der Standortgruppe static hinzufügen
Dieser Schritt ist nur erforderlich, wenn Sie zuvor eine Asset-Sammlung für statische Standortgruppen erstellt haben.
- Verwenden Sie den Bericht
asset_set_asset, um die Ressourcennamen von Assets abzurufen, die automatisch für die zuvor erstellte Asset-Sammlung für die Standortsynchronisierung generiert wurden. Mit Filtern können Sie nur die gewünschten Assets abrufen. - Fügen Sie sie dem Asset-Set für statische Standortgruppen mit
AssetSetAssetService.MutateAssetSetAssetshinzu.
Standort-IDs für Unternehmensprofile verwalten
Wenn Sie ein business_profile_location_set verwenden und nach listing_id_filters filtern, die von der Business Profile-Website oder ‑API abgerufen werden, müssen Sie diese numerischen Werte möglicherweise vom Typ uint64 in int64 konvertieren. Wenn Ihr Code einen Laufzeitfehler generiert, der besagt, dass Ihre Unternehmensprofil-Standort-ID außerhalb des zulässigen Bereichs liegt, wenn Sie sie dem wiederholten Feld listing_id_filters[] hinzufügen, müssen Sie sie wahrscheinlich mit einem der folgenden Beispiele konvertieren:
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 < 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;
}
}