A differenza di altri asset, gli asset posizione vengono creati automaticamente dall'API Google Ads dopo la creazione di un insieme di asset. Per prima cosa, crea un insieme di asset di sincronizzazione della posizione e collegalo al cliente. Poi, se devi selezionare un sottoinsieme degli asset posizione nel gruppo di asset per una campagna o un gruppo di annunci, crea un gruppo di asset posizione e collegalo alla campagna o al gruppo di annunci.
Crea un insieme di asset di sincronizzazione della posizione e collegalo al cliente
- Crea un insieme di asset di sincronizzazione della posizione.
- Allegalo a un cliente utilizzando
CustomerAssetSetService
.
Creare un insieme di asset di sincronizzazione della posizione
- Crea un nuovo
AssetSet
.- Imposta
type
suLOCATION_SYNC
. - Imposta
location_set
su un nuovoLocationSet
.
- Imposta
- Nella nuova
LocationSet
,- Imposta
location_ownership_type
in base al tuo caso d'uso:- Imposta il valore su
BUSINESS_OWNER
se sei il proprietario della sede dell'attività. - Impostalo su
AFFILIATE
se non possiedi la sede dell'attività, ma vendi i tuoi prodotti in quella sede.
- Imposta il valore su
- Imposta il campo oneof
source
in base al tuo caso d'uso:- Imposta
business_profile_location_set
se vuoi eseguire la sincronizzazione con le tue sedi nell'account Profilo dell'attività su Google. - Imposta
chain_location_set
se vuoi eseguire la sincronizzazione con le sedi negli ID catena specificati. - Imposta
maps_location_set
se vuoi aggiungere manualmente le sedi utilizzando gli ID luogo.
- Imposta
- Imposta
Dopo aver completato questi passaggi, l'API Google Ads genera asset di località e li aggiunge al set di asset di sincronizzazione delle località creato per te, in modo simile a quando lo fai manualmente utilizzando AssetSetAssetService
. Non è necessario
manipolarli, a meno che tu non voglia aggiungerli manualmente a un gruppo di asset di località statiche.
Per un cliente può esistere un solo set di asset di sincronizzazione della posizione attivo con
(status
di
ENABLED
). Se devi creare un altro tipo di set di asset di sincronizzazione delle sedi, rimuovi prima quello esistente.
Collega il gruppo di asset di sincronizzazione della posizione a un cliente
Utilizza
CustomerAssetSetService.MutateCustomerAssetSets
per collegare al cliente il gruppo di asset di sincronizzazione della posizione impostato nella sezione precedente.
(Facoltativo) Crea un insieme di asset gruppo di località e collegalo a una campagna o a un gruppo di annunci
Un insieme di asset gruppo di località è necessario solo se devi selezionare un sottoinsieme di asset posizione. Ciò è dovuto al fatto che le campagne e i gruppi di annunci ereditano gli asset posizione a livello di cliente.
I set di asset dei gruppi di località contengono un sottoinsieme di asset posizione del set di asset sincronizzazione delle posizioni. Puoi creare dinamicamente un insieme di asset del gruppo di località sfruttando alcune funzionalità di Profilo dell'attività su Google (come il filtro per etichette) o ID catena e sedi della catena. In alternativa, puoi creare staticamente un insieme di asset del gruppo di località.
- Crea un set di asset del gruppo di località. Il set di asset del gruppo di località può essere dinamico o statico.
- Collega il set di asset a una campagna o a un gruppo di annunci, a seconda delle tue esigenze.
- (Facoltativo) Aggiungi gli asset generati in precedenza al set di asset del gruppo di località statiche appena creato.
Per un determinato cliente, puoi creare più set di asset di gruppi di sedi dinamici o statici.
Crea un insieme di asset del gruppo di località
Crea un nuovo AssetSet
e imposta
location_group_parent_asset_set_id
sull'ID del set di asset di sincronizzazione della posizione
creato in precedenza.
Poi, imposta alcuni campi a seconda che tu voglia creare un insieme di asset gruppo di località dinamico o statico.
Set di asset dinamici
A seconda del campo impostato in LocationSet
, imposta
i campi in base alla seguente regola:
Se imposti il seguente campo | Poi imposta type su | e imposta questo campo come campo 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 |
Se imposti maps_location_set
quando crei il set di asset di sincronizzazione della posizione, non potrai creare un set di asset di gruppo di località dinamico. Questo perché hai aggiunto manualmente le località tramite ID luogo
e non sono disponibili funzionalità di filtro che puoi utilizzare per questo tipo di località.
Set di asset statici
Imposta type
su
STATIC_LOCATION_GROUP
.
Puoi creare set di asset di gruppi di località statici per qualsiasi tipo di set di asset di sincronizzazione delle località, indipendentemente dai campi (business_profile_location_set
, chain_location_set
o maps_location_set
) impostati in LocationSet
.
Per i set di asset dei gruppi di località statici, devi aggiungere manualmente gli asset posizione generati ai set di asset dei gruppi di località.
Allegare il gruppo di asset a una campagna o a un gruppo di annunci
Utilizza
CampaignAssetSetService.MutateCampaignAssetSets
per collegare il set di asset gruppo di località alla tua
campagna.
In alternativa, utilizza
AdGroupAssetSetService.MutateAdGroupAssetSets
se vuoi collegare il set di asset gruppo di località a
un gruppo di annunci.
(Facoltativo) Aggiungi gli asset posizione al set di asset del gruppo di sedi statico
Questo passaggio è obbligatorio solo se in precedenza hai creato un insieme di asset del gruppo di località statico.
- Utilizza il report
asset_set_asset
per recuperare i nomi delle risorse degli asset generati automaticamente per il set di asset di sincronizzazione della posizione creato in precedenza. Utilizza i filtri per recuperare solo le risorse che ti interessano. - Aggiungili al set di asset del gruppo di località statico utilizzando
AssetSetAssetService.MutateAssetSetAssets
.
Gestire gli ID località del profilo dell'attività
Quando utilizzi un business_profile_location_set
e filtri in base a
listing_id_filters
recuperati dal sito web o dall'API Business Profile, potrebbe essere necessario
convertire questi valori numerici dal tipo uint64
a int64
. Se il tuo codice
genera un errore di runtime che indica che l'ID sede del profilo dell'attività non rientra nell'intervallo
quando lo aggiungi al campo ripetuto listing_id_filters[], probabilmente devi
convertirlo utilizzando uno dei seguenti esempi:
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;
}
}