בשונה מנכסים אחרים, נכסי מיקום נוצרים באופן אוטומטי על ידי 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 כדי לצרף את קבוצת נכסי סנכרון המיקומים שהוגדרה בקטע הקודם ללקוח.
(אופציונלי) יצירה של קבוצת נכסים של קבוצות לפי מיקום וצירופה לקמפיין או לקבוצת מודעות
צריך להשתמש בנכס מסוג קבוצה לפי מיקום רק אם רוצים לבחור קבוצת משנה של נכסי מיקום. הסיבה לכך היא שהקמפיינים והקבוצות של המודעות יורשים נכסי מיקום מרמת הלקוח.
קבוצות של נכסי מיקום מכילות קבוצת משנה של נכסי מיקום מתוך קבוצת הנכסים location sync. אתם יכולים ליצור באופן דינמי קבוצת נכסים של מיקומים באמצעות תכונות מסוימות של פרופיל העסק ב-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.
ניהול מזהי מיקומים בפרופיל העסק ב-Google
כשמשתמשים ב-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 < 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;
}
}