בשונה מנכסים אחרים, נכסי מיקום נוצרים באופן אוטומטי על ידי Google Ads API אחרי שיוצרים קבוצת נכסים. קודם יוצרים קבוצת נכסים לסנכרון מיקומים ומקשרים אותה ללקוח. לאחר מכן, אם אתם צריכים לבחור קבוצת משנה של נכסי המיקום בסט הנכסים של קמפיין או קבוצת מודעות, אתם יכולים ליצור סט נכסים של קבוצה לפי מיקום ולצרף אותו לקמפיין או לקבוצת המודעות.
יצירת קבוצת נכסים לסנכרון מיקומים וצירוף שלה ללקוח
יצירת קבוצת נכסים לסנכרון מיקומים
- יוצרים
AssetSet
חדש.- מגדירים את
type
לערךLOCATION_SYNC
. - מגדירים את
location_set
לערך חדש שלLocationSet
.
- מגדירים את
- בכרטיס החדש
LocationSet
,- מגדירים את
location_ownership_type
בהתאם לתרחיש השימוש:- מגדירים את האפשרות
BUSINESS_OWNER
אם אתם הבעלים של מיקום העסק. - מגדירים את הערך ל-
AFFILIATE
אם אתם לא הבעלים של מיקום העסק, אבל אתם מוכרים בו את המוצרים שלכם.
- מגדירים את האפשרות
- מגדירים את
source
שדה oneof בהתאם לתרחיש לדוגמה:- מגדירים
business_profile_location_set
אם רוצים לסנכרן עם המיקומים בחשבון פרופיל העסק ב-Google. - מגדירים את
chain_location_set
אם רוצים לסנכרן עם מיקומים במזהי רשתות ספציפיים. - מגדירים את
maps_location_set
אם רוצים להוסיף מיקומים באופן ידני באמצעות מזהי מקומות.
- מגדירים
- מגדירים את
אחרי שמשלימים את השלבים האלה, Google Ads API יוצר נכסי מיקום ומוסיף אותם לקבוצת נכסי סנכרון המיקום שנוצרה בשבילכם, בדומה למצב שבו אתם עושים זאת באופן ידני באמצעות AssetSetAssetService
. אין צורך לשנות אותם, אלא אם רוצים להוסיף אותם באופן ידני לנכסי קבוצת מיקומים סטטית.
יכול להיות ללקוח רק נכס פעיל אחד של סנכרון מיקומים עם (status
מתוך ENABLED
). אם אתם צריכים ליצור סוג אחר של נכס לסנכרון מיקומים, אתם צריכים להסיר קודם את הנכס הקיים.
צירוף קבוצת נכסי סנכרון מיקומים ללקוח
משתמשים ב-CustomerAssetSetService.MutateCustomerAssetSets
כדי לצרף את נכס סנכרון המיקומים שהוגדר בקטע הקודם ללקוח.
(אופציונלי) יצירה של קבוצת נכסים של קבוצה לפי מיקום וצירופה לקמפיין או לקבוצת מודעות
צריך להשתמש בנכס מסוג קבוצה לפי מיקום רק אם רוצים לבחור קבוצת משנה של נכסי מיקום. הסיבה לכך היא שהקמפיינים והקבוצות של המודעות יורשים נכסי מיקום מרמת הלקוח.
קבוצות נכסים לפי מיקום מכילות קבוצת משנה של נכסי מיקום מתוך קבוצת הנכסים סנכרון מיקומים. אתם יכולים ליצור באופן דינמי קבוצת נכסים של מיקומים באמצעות תכונות מסוימות של פרופיל העסק ב-Google (כמו סינון לפי תוויות) או מזהי רשתות ומיקומי רשתות. אפשרות אחרת היא ליצור באופן סטטי קבוצת נכסים של קבוצת מיקומים.
- יצירת קבוצת נכסים של קבוצת מיקומים. קבוצת הנכסים לפי מיקום יכולה להיות דינמית או סטטית.
- מצרפים את קבוצת הנכסים לקמפיין או לקבוצת מודעות, בהתאם לצורך.
- (אופציונלי) מוסיפים את הנכסים שנוצרו קודם לסט הנכסים החדש של קבוצת מיקומים סטטיים.
אפשר ליצור כמה קבוצות נכסים של קבוצות מיקומים דינמיות או סטטיות ללקוח מסוים.
יצירה של קבוצת נכסים של קבוצה לפי מיקום
יוצרים AssetSet
חדש ומגדירים את location_group_parent_asset_set_id
למזהה של קבוצת נכסי סנכרון המיקומים שנוצרה קודם.
לאחר מכן, מגדירים כמה שדות בהתאם לסוג קבוצת המיקומים שרוצים ליצור: דינמית או סטטית.
קבוצות נכסים דינמיות
בהתאם לשדה שהגדרתם ב-LocationSet
, מגדירים את השדות לפי הכלל הבא:
אם מגדירים את השדה הבא | לאחר מכן מגדירים את הסוג ל- | ומגדירים את השדה הזה כשדה 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;
}
}