Standort-Assets

Im Gegensatz zu anderen Assets werden Standort-Assets automatisch von der Google Ads API erstellt, nachdem Sie eine Asset-Sammlung erstellt haben. Erstellen Sie zuerst eine Asset-Sammlung für die Standortsynchronisierung und verknüpfen Sie sie mit dem Kunden. Wenn Sie dann eine Teilmenge der Standort-Assets in der Asset-Sammlung für eine Kampagne oder Anzeigengruppe auswählen müssen, erstellen Sie eine Asset-Sammlung für Standortgruppen und hängen Sie sie an die Kampagne oder Anzeigengruppe an.

Asset-Sammlung für die Standortsynchronisierung erstellen und mit dem Kunden verknüpfen

  1. Erstellen Sie eine Asset-Sammlung für die Standortsynchronisierung.
  2. Hängen Sie es mit CustomerAssetSetService an einen Kunden an.

Asset-Set für die Standortsynchronisierung erstellen

  1. Erstellen Sie eine neue AssetSet.
    1. Setzen Sie type auf LOCATION_SYNC.
    2. Legen Sie für location_set einen neuen LocationSet fest.
  2. Im neuen LocationSet

    1. Legen Sie location_ownership_type basierend auf Ihrem Anwendungsfall fest:
      • Legen Sie den Wert auf BUSINESS_OWNER fest, wenn Sie der Inhaber des Standorts sind.
      • Legen Sie den Wert auf AFFILIATE fest, wenn Sie nicht der Inhaber des Geschäftsstandorts sind, aber Ihre Produkte dort verkaufen.
    2. Legen Sie das Oneof-Feld source entsprechend Ihrem Anwendungsfall fest:

      • Legen Sie business_profile_location_set fest, wenn Sie die Standorte in Ihrem Google Unternehmensprofil-Konto synchronisieren möchten.

        Wenn Sie ein BusinessProfileLocationSet erstellen, um Google Ads mit einem Google Unternehmensprofil-Konto zu verknüpfen, müssen Sie im Feld http_authorization_token ein OAuth 2.0-Zugriffstoken angeben. Dieses Token dient als Nachweis, dass Sie Google Ads autorisieren, auf die Standortdaten aus dem angegebenen Google 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_address der BusinessProfileLocationSet angegeben ist.
        • Dieses Konto muss ausreichende Berechtigungen haben, um die Unternehmensstandorte im Google Unternehmensprofil zu lesen.
        • Das OAuth 2.0-Token muss mit dem Bereich https://www.googleapis.com/auth/business.manage abgerufen werden.

        Eine ausführliche Anleitung zum Generieren eines OAuth 2.0-Zugriffstokens finden Sie unter OAuth 2.0 für den Zugriff auf Google APIs verwenden.

      • Legen Sie chain_location_set fest, wenn Sie mit Standorten in bestimmten Ketten-IDs synchronisieren möchten.

      • Legen Sie maps_location_set fest, wenn Sie Orte manuell mithilfe von Orts-IDs hinzufügen möchten.

Nachdem Sie diese Schritte ausgeführt haben, generiert die Google Ads API Standort-Assets und fügt sie der erstellten Asset-Sammlung für die Standortsynchronisierung hinzu. Das ist vergleichbar mit dem manuellen Hinzufügen ü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-Sammlung für die Standortsynchronisierung erstellen möchten, müssen Sie die vorhandene zuerst entfernen.

Asset-Sammlung für die Standortsynchronisierung mit einem Kunden verknüpfen

Verwenden Sie CustomerAssetSetService.MutateCustomerAssetSets, um die im vorherigen Abschnitt festgelegte Asset-Sammlung für die Standortsynchronisierung mit Ihrem Kundenkonto zu verknüpfen.

Optional: Asset-Sammlung für Standortgruppen erstellen und einer Kampagne oder Anzeigengruppe zuweisen

Eine Asset-Sammlung 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 von der Kundenebene übernehmen.

Asset-Sammlungen für Standortgruppen enthalten eine Teilmenge der Standort-Assets der Asset-Sammlung für die Standortsynchronisierung. Sie können eine Asset-Sammlung für Standortgruppen dynamisch erstellen, indem Sie einige Funktionen von Google Unternehmensprofil (z. B. Filtern nach Labels) oder Ketten-IDs und Kettenstandorte verwenden. Alternativ können Sie eine Asset-Sammlung für Standortgruppen statisch erstellen.

  1. Asset-Sammlung für Standortgruppen erstellen Die Asset-Sammlung für Standortgruppen kann dynamisch oder statisch sein.
  2. Verknüpfen Sie die Asset-Sammlung je nach Bedarf mit einer Kampagne oder einer Anzeigengruppe.
  3. Optional: Fügen Sie die zuvor generierten Assets der neu erstellten Asset-Sammlung für statische Standortgruppen hinzu.

Für einen bestimmten Kunden können Sie mehrere Asset-Sammlungen für dynamische oder statische Standortgruppen erstellen.

Asset-Sammlung für Standortgruppen erstellen

Erstellen Sie ein neues AssetSet und legen Sie für location_group_parent_asset_set_id die ID der zuvor erstellten Asset-Sammlung für die Standortsynchronisierung fest.

Legen Sie dann einige Felder fest, je nachdem, ob Sie ein Asset-Set für eine dynamische oder statische Standortgruppe erstellen möchten.

Dynamische Asset-Sammlungen

Legen Sie die Felder je nach dem Feld, das Sie in LocationSet festgelegt haben, anhand der folgenden Regel fest:

Wenn Sie das folgende Feld festlegen Legen Sie dann type auf Legen Sie dieses Feld als Oneof-Feld asset_set_source 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 Asset-Sammlung für dynamische Standortgruppen erstellen. Das liegt daran, dass Sie Standorte manuell über Orts-IDs hinzugefügt haben und für diese Art von Standorten keine Filterfunktionen verfügbar sind.

Statische Asset-Sammlungen

Setzen Sie type auf STATIC_LOCATION_GROUP. Sie können statische Asset-Sammlungen für Standortgruppen für alle Arten von Asset-Sammlungen für die Standortsynchronisierung erstellen, unabhängig davon, welche Felder (business_profile_location_set, chain_location_set oder maps_location_set) Sie im LocationSet festlegen.

Bei statischen Asset-Sammlungen für Standortgruppen müssen Sie die generierten Standort-Assets manuell zu den Asset-Sammlungen für Standortgruppen hinzufügen.

Asset-Sammlung einer Kampagne oder Anzeigengruppe hinzufügen

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: Fügen Sie die Standort-Assets der statischen Asset-Sammlung für Standortgruppen hinzu.

Dieser Schritt ist nur erforderlich, wenn Sie zuvor ein Asset-Set für eine statische Standortgruppe erstellt haben.

  1. Verwenden Sie den Bericht asset_set_asset, um die Ressourcennamen der Assets abzurufen, die automatisch für die zuvor erstellte Asset-Sammlung für die Standortsynchronisierung generiert wurden. Verwenden Sie Filter, um nur die gewünschten Assets abzurufen.
  2. Fügen Sie sie mit AssetSetAssetService.MutateAssetSetAssets dem Asset-Set für statische Standortgruppen hinzu.

Standort-IDs für Unternehmensprofile verwalten

Wenn Sie einen business_profile_location_set verwenden und nach listing_id_filters filtern, die von der Google Unternehmensprofil-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 die Standort-ID Ihres Unternehmensprofils außerhalb des zulässigen Bereichs liegt, wenn Sie sie dem wiederkehrenden 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;
  }
}