בשונה מנכסים אחרים, נכסי מיקום נוצרים באופן אוטומטי על ידי Google Ads API אחרי שיוצרים קבוצת נכסים. קודם כול, יוצרים קבוצת נכסים לסנכרון מיקומים ומצרפים אותה ללקוח. לאחר מכן, אם אתם צריכים לבחור קבוצת משנה של נכסי המיקום בסט הנכסים של קמפיין או קבוצת מודעות, אתם יכולים ליצור סט נכסים של קבוצה לפי מיקום ולצרף אותו לקמפיין או לקבוצת המודעות.
יצירת קבוצת נכסים לסנכרון מיקומים וצירוף שלה ללקוח
יצירת קבוצת נכסים לסנכרון מיקומים
- יוצרים
AssetSetחדש.- מגדירים את
typeלערךLOCATION_SYNC. - מגדירים את
location_setלערך חדש שלLocationSet.
- מגדירים את
בכרטיס החדש
LocationSet,- מגדירים את
location_ownership_typeבהתאם לתרחיש לדוגמה:- מגדירים את האפשרות
BUSINESS_OWNERאם אתם הבעלים של מיקום העסק. - מגדירים את הערך ל-
AFFILIATEאם אתם לא הבעלים של מיקום העסק, אבל אתם מוכרים בו את המוצרים שלכם.
- מגדירים את האפשרות
מגדירים את שדה
sourceoneof בהתאם לתרחיש השימוש:מגדירים
business_profile_location_setאם רוצים לסנכרן עם המיקומים בחשבון פרופיל העסק ב-Google.כשיוצרים
BusinessProfileLocationSetכדי לקשר את Google Ads לחשבון פרופיל העסק ב-Google, צריך לספק אסימון גישה מסוג OAuth 2.0 בשדהhttp_authorization_token. האסימון הזה משמש כהוכחה לכך שאתם מאשרים ל-Google Ads לגשת לנתוני המיקום מפרופיל העסק הספציפי ב-Google.הטוקן צריך לעמוד בדרישות הבאות:
- הוא צריך להיווצר עבור חשבון Google (משתמש או חשבון שירות) שכתובת האימייל שלו מופיעה בשדה
email_addressשלBusinessProfileLocationSet. - לחשבון הזה צריכות להיות הרשאות מספיקות לקריאת המיקומים של העסק בפרופיל העסק ב-Google.
- צריך לקבל את אסימון OAuth 2.0 עם ההיקף
https://www.googleapis.com/auth/business.manage.
הוראות מפורטות ליצירת אסימון גישה מסוג OAuth 2.0 זמינות במאמר שימוש ב-OAuth 2.0 כדי לגשת אל Google APIs.
- הוא צריך להיווצר עבור חשבון Google (משתמש או חשבון שירות) שכתובת האימייל שלו מופיעה בשדה
מגדירים את
chain_location_setאם רוצים לסנכרן עם מיקומים במזהי רשתות ספציפיים.מגדירים
maps_location_setאם רוצים להוסיף מיקומים באופן ידני באמצעות מזהי מקומות.
- מגדירים את
אחרי שמשלימים את השלבים האלה, Google Ads API יוצר נכסי מיקום ומוסיף אותם לקבוצת נכסי סנכרון המיקום שנוצרה בשבילכם, בדומה למצב שבו אתם עושים זאת באופן ידני באמצעות AssetSetAssetService. אין צורך לשנות אותם, אלא אם רוצים להוסיף אותם באופן ידני לנכסי קבוצת מיקומים סטטית.
יכולה להיות ללקוח רק קבוצה אחת של נכסי מיקום פעילים עם (status מתוך ENABLED). אם אתם צריכים ליצור סוג אחר של נכס לסנכרון מיקומים, אתם צריכים קודם להסיר את הנכס הקיים.
צירוף קבוצת נכסי סנכרון מיקומים ללקוח
משתמשים ב-CustomerAssetSetService.MutateCustomerAssetSets כדי לצרף את נכס סנכרון המיקומים שהוגדר בקטע הקודם ללקוח.
(אופציונלי) יצירה של קבוצת נכסים של קבוצה לפי מיקום וצירופה לקמפיין או לקבוצת מודעות
צריך להשתמש בנכס מסוג קבוצה לפי מיקום רק אם רוצים לבחור קבוצת משנה של נכסי מיקום. הסיבה לכך היא שהקמפיינים והקבוצות של המודעות יורשים נכסי מיקום מרמת הלקוח.
קבוצות נכסים לפי מיקום מכילות קבוצת משנה של נכסי מיקום מתוך קבוצת הנכסים סנכרון מיקומים. אתם יכולים ליצור באופן דינמי קבוצת נכסים של מיקומים באמצעות תכונות מסוימות של פרופיל העסק ב-Google (כמו סינון לפי תוויות) או מזהי רשתות ומיקומי רשתות. אפשרות אחרת היא ליצור באופן סטטי קבוצת נכסים של קבוצת מיקומים.
- יוצרים קבוצת נכסים של קבוצת מיקומים. קבוצת הנכסים לפי מיקום יכולה להיות דינמית או סטטית.
- מצרפים את קבוצת הנכסים לקמפיין או לקבוצת מודעות, בהתאם לצורך.
- (אופציונלי) מוסיפים את הנכסים שנוצרו קודם לסט הנכסים החדש של קבוצת מיקומים סטטיים.
לכל לקוח אפשר ליצור כמה קבוצות מיקומים דינמיות או סטטיות.
יצירה של קבוצת נכסים של קבוצה לפי מיקום
יוצרים AssetSet חדש ומגדירים את location_group_parent_asset_set_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 כשיוצרים את קבוצת נכסי המיקום לסנכרון, לא תהיה אפשרות ליצור קבוצת נכסי מיקום דינמיים. הסיבה לכך היא שהוספתם מיקומים באופן ידני באמצעות מזהי מקומות, ואין תכונות סינון שאפשר להשתמש בהן עבור סוג המיקומים הזה.
קבוצות נכסים סטטיות
מגדירים את type לערך STATIC_LOCATION_GROUP.
אפשר ליצור קבוצות נכסים סטטיות של מיקומים לכל סוג של קבוצת נכסים לסינכרון מיקומים, בלי קשר לשדות (business_profile_location_set, chain_location_set או maps_location_set) שהגדרתם ב-LocationSet.
במערכי נכסים של קבוצות לפי מיקום שהם סטטיים, צריך להוסיף ידנית את נכסי המיקום שנוצרו למערכי הנכסים של הקבוצות לפי מיקום.
צירוף קבוצת הנכסים לקמפיין או לקבוצת מודעות
משתמשים ב-CampaignAssetSetService.MutateCampaignAssetSets כדי לצרף את קבוצת הנכסים של קבוצות לפי מיקום לקמפיין.
אפשרות אחרת היא להשתמש ב-AdGroupAssetSetService.MutateAdGroupAssetSets אם רוצים לצרף את קבוצת הנכסים של קבוצת המיקומים לקבוצת מודעות.
(אופציונלי) מוסיפים את נכסי המיקום לסט הנכסים של קבוצת המיקומים הסטטית
השלב הזה נדרש רק אם יצרתם בעבר קבוצת נכסי מיקום סטטית.
- אפשר להשתמש בדוח
asset_set_assetכדי לאחזר את שמות המשאבים של נכסים שנוצרו באופן אוטומטי עבור קבוצת נכסי סנכרון המיקום שנוצרה קודם. כדי לאחזר רק את הנכסים שרוצים, אפשר להשתמש בסינון. - מוסיפים אותם לקבוצה סטטית של נכסים לחיפוש מפיצים באמצעות
AssetSetAssetService.MutateAssetSetAssets.
ניהול מזהי מיקומים בפרופיל העסק
כשמשתמשים ב-business_profile_location_set ומסננים לפי listing_id_filters שאוחזרו מאתר פרופיל העסק או מ-API, יכול להיות שיהיה צורך להמיר את הערכים המספריים האלה מסוג uint64 לסוג int64. אם הקוד שלכם יוצר שגיאת זמן ריצה שקשורה למזהה מיקום של פרופיל העסק שנמצא מחוץ לטווח כשמוסיפים אותו לשדה החוזר listing_id_filters[], כנראה שצריך להמיר אותו באמצעות אחת מהדוגמאות הבאות:
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;
}
}