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