ชิ้นงานสถานที่ตั้งจะสร้างขึ้นโดยอัตโนมัติโดย Google Ads API หลังจากที่คุณสร้างชุดชิ้นงาน ซึ่งแตกต่างจากชิ้นงานอื่นๆ ขั้นแรก ให้สร้างชุดชิ้นงานการซิงค์สถานที่ตั้งและแนบชุดชิ้นงานดังกล่าวกับลูกค้า จากนั้นหากต้องการเลือกชิ้นงานสถานที่ตั้งบางส่วนในชุดชิ้นงานสำหรับแคมเปญหรือกลุ่มโฆษณา ให้สร้างชุดชิ้นงานกลุ่มสถานที่ตั้งและแนบชุดชิ้นงานดังกล่าวกับแคมเปญหรือกลุ่มโฆษณา
สร้างชุดชิ้นงานการซิงค์สถานที่ตั้งและแนบชุดชิ้นงานดังกล่าวกับลูกค้า
สร้างชุดชิ้นงานการซิงค์สถานที่ตั้ง
- สร้าง
AssetSetใหม่- ตั้งค่า
typeเป็นLOCATION_SYNC - ตั้งค่า
location_setเป็นLocationSetใหม่
- ตั้งค่า
ใน
LocationSetใหม่ ให้ทำดังนี้- ตั้งค่า
location_ownership_typeตามกรณีการใช้งานของคุณ ดังนี้- ตั้งค่าเป็น
BUSINESS_OWNERหากคุณเป็นเจ้าของที่ตั้งธุรกิจ - ตั้งค่าเป็น
AFFILIATEหากคุณไม่ได้เป็นเจ้าของที่ตั้งธุรกิจ แต่ขายผลิตภัณฑ์ ที่นั่น
- ตั้งค่าเป็น
ตั้งค่าฟิลด์
sourceoneof ตามกรณีการใช้งานของคุณ ดังนี้ตั้งค่า
business_profile_location_setหากต้องการซิงค์กับ สถานที่ตั้งใน บัญชี Google Business Profileเมื่อสร้าง
BusinessProfileLocationSetเพื่อลิงก์ Google Ads กับบัญชี Google Business Profile คุณต้องระบุโทเค็นเพื่อการเข้าถึง OAuth 2.0 ในฟิลด์http_authorization_tokenโทเค็นนี้ทำหน้าที่เป็นหลักฐานว่าคุณอนุญาตให้ Google Ads เข้าถึงข้อมูลสถานที่ตั้งจาก Google Business Profile ที่ระบุโทเค็นต้องเป็นไปตามข้อกำหนดต่อไปนี้
- ต้องสร้างขึ้นสำหรับบัญชี Google (บัญชีผู้ใช้หรือบัญชีบริการ) ที่ระบุอีเมลในฟิลด์
email_addressของBusinessProfileLocationSet - บัญชีนี้ต้องมีสิทธิ์ที่เพียงพอในการอ่านสถานที่ตั้งของธุรกิจภายใน Google Business Profile
- ต้องได้รับโทเค็น OAuth 2.0 ด้วยขอบเขต
https://www.googleapis.com/auth/business.manage
ดูวิธีการสร้างโทเค็นเพื่อการเข้าถึง OAuth 2.0 โดยละเอียดได้ที่ การใช้ OAuth 2.0 เพื่อเข้าถึง Google API
- ต้องสร้างขึ้นสำหรับบัญชี Google (บัญชีผู้ใช้หรือบัญชีบริการ) ที่ระบุอีเมลในฟิลด์
ตั้งค่า
chain_location_setหากต้องการซิงค์กับสถานที่ตั้งในรหัสเชนที่ระบุตั้งค่า
maps_location_setหากต้องการเพิ่มสถานที่ตั้งด้วยตนเองโดยใช้ รหัสสถานที่
- ตั้งค่า
หลังจากทำตามขั้นตอนเหล่านี้เสร็จแล้ว Google Ads API จะสร้างชิ้นงาน
สถานที่ตั้ง และเพิ่มชิ้นงานดังกล่าวลงในชุดชิ้นงานการซิงค์สถานที่ตั้งที่สร้างขึ้นให้คุณ ซึ่งคล้าย
กับเมื่อคุณดำเนินการด้วยตนเองโดยใช้
AssetSetAssetService คุณไม่จำเป็นต้อง
จัดการชิ้นงานเหล่านี้ เว้นแต่ว่าต้องการเพิ่มชิ้นงานดังกล่าวลงในชุดชิ้นงานกลุ่มสถานที่ตั้งแบบคงที่ด้วยตนเอง
ลูกค้า 1 รายจะมีชุดชิ้นงานการซิงค์สถานที่ตั้งที่ใช้งานอยู่ได้เพียงชุดเดียวที่มี
(status เป็น
ENABLED) หากต้องการสร้างชุดชิ้นงานการซิงค์สถานที่ตั้งประเภทอื่น ให้ลบชุดชิ้นงานที่มีอยู่ออกก่อน
แนบชุดชิ้นงานการซิงค์สถานที่ตั้งกับลูกค้า
ใช้
CustomerAssetSetService.MutateCustomerAssetSets
เพื่อแนบชุดชิ้นงานการซิงค์สถานที่ตั้งในส่วนก่อนหน้ากับลูกค้า
(ไม่บังคับ) สร้างชุดชิ้นงานกลุ่มสถานที่ตั้งและแนบชุดชิ้นงานดังกล่าวกับแคมเปญหรือกลุ่มโฆษณา
คุณต้องสร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง ก็ต่อเมื่อต้องการเลือกชิ้นงานสถานที่ตั้งบางส่วนเท่านั้น เนื่องจากแคมเปญและกลุ่มโฆษณาจะรับช่วงชิ้นงานสถานที่ตั้งจากระดับลูกค้า
ชุดชิ้นงานกลุ่มสถานที่ตั้งจะมีชิ้นงานสถานที่ตั้งบางส่วนจากชุดชิ้นงานการซิงค์สถานที่ตั้ง คุณสามารถสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบไดนามิกได้โดยใช้ประโยชน์จากฟีเจอร์บางอย่างของ Google Business Profile (เช่น การกรองตามป้ายกำกับ) หรือรหัสเครือข่ายและสถานที่ตั้งของเครือข่าย หรือจะสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบคงที่ก็ได้
- สร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง ชุดชิ้นงานกลุ่มสถานที่ตั้งอาจเป็นแบบไดนามิก หรือคงที่
- แนบชุดชิ้นงานกับแคมเปญโดยใช้ `CampaignAssetSetService.MutateCampaignAssetSets` หรือกับกลุ่มโฆษณาโดยใช้ `AdGroupAssetSetService.MutateAdGroupAssetSets` ทั้งนี้ขึ้นอยู่กับ ความต้องการ
- (ไม่บังคับ) เพิ่มชิ้นงานที่สร้างไว้ก่อนหน้านี้ลงในชุดชิ้นงานกลุ่มสถานที่ตั้งแบบคงที่ที่สร้างขึ้นใหม่
คุณสามารถสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบไดนามิกหรือแบบคงที่หลายชุดสำหรับลูกค้า 1 ราย
สร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง
สร้าง AssetSet ใหม่และตั้งค่า
location_group_parent_asset_set_id เป็นรหัสของชุดชิ้นงานการซิงค์สถานที่ตั้งที่สร้างไว้ก่อนหน้านี้
จากนั้นตั้งค่าฟิลด์บางรายการตามที่คุณต้องการสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบไดนามิกหรือแบบคงที่
ชุดชิ้นงานแบบไดนามิก
ตั้งค่าฟิลด์ตามกฎต่อไปนี้ ทั้งนี้ขึ้นอยู่กับฟิลด์ที่คุณ ตั้งค่าใน LocationSet
| หากคุณตั้งค่าฟิลด์ต่อไปนี้ | ให้ตั้งค่า ประเภท เป็น | และตั้งค่าฟิลด์นี้เป็นฟิลด์ asset_set_source oneof field |
|---|---|---|
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
เมื่อคุณใช้ business_profile_location_set และกรอง
listing_id_filters
ที่ดึงมาจากเว็บไซต์หรือ API ของ Business Profile คุณอาจต้อง
แปลงค่าตัวเลขเหล่านี้จากประเภท uint64 เป็น int64 หากโค้ดสร้างข้อผิดพลาดรันไทม์ว่ารหัสสถานที่ตั้ง Business Profile อยู่นอกช่วงเมื่อเพิ่มรหัสสถานที่ตั้งลงในฟิลด์ที่ซ้ำกัน 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;
}
}