ชิ้นงานสถานที่ตั้งแตกต่างจากชิ้นงานอื่นๆ ตรงที่ Google Ads API จะสร้างชิ้นงานสถานที่ตั้งโดยอัตโนมัติ หลังจากที่คุณสร้างชุดชิ้นงาน ก่อนอื่น ให้สร้างชุดชิ้นงานการซิงค์สถานที่ตั้งและ แนบชุดชิ้นงานกับลูกค้า จากนั้นหากต้องการเลือกชุดย่อยของชิ้นงานสถานที่ตั้ง ในชุดชิ้นงานสําหรับแคมเปญหรือกลุ่มโฆษณา ให้สร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง และแนบไปกับแคมเปญหรือกลุ่มโฆษณา
สร้างชุดชิ้นงานการซิงค์สถานที่ตั้งและแนบชุดชิ้นงานกับลูกค้า
สร้างชุดชิ้นงานการซิงค์สถานที่ตั้ง
- สร้าง
AssetSet
ใหม่- ตั้งค่า
type
เป็นLOCATION_SYNC
- ตั้งค่า
location_set
เป็นLocationSet
ใหม่
- ตั้งค่า
- ใน
LocationSet
ใหม่ ให้ทำดังนี้- ตั้งค่า
location_ownership_type
ตามกรณีการใช้งานของคุณ- ตั้งค่าเป็น
BUSINESS_OWNER
หากคุณเป็นเจ้าของที่ตั้งธุรกิจ - ตั้งค่าเป็น
AFFILIATE
หากคุณไม่ได้เป็นเจ้าของสถานที่ตั้งธุรกิจ แต่ขายผลิตภัณฑ์ ที่นั่น
- ตั้งค่าเป็น
- ตั้งค่า
source
ฟิลด์ oneof ตามกรณีการใช้งานของคุณ ดังนี้- ตั้งค่า
business_profile_location_set
หากต้องการซิงค์กับสถานที่ตั้งในบัญชี Google Business Profile - ตั้งค่า
chain_location_set
หากต้องการซิงค์กับสถานที่ตั้งใน รหัสเชนที่ระบุ - ตั้งค่า
maps_location_set
หากต้องการเพิ่มสถานที่ตั้งด้วยตนเองโดยใช้รหัสสถานที่
- ตั้งค่า
- ตั้งค่า
หลังจากทำตามขั้นตอนเหล่านี้เสร็จแล้ว Google Ads API จะสร้างชิ้นงาน
สถานที่ตั้งและเพิ่มลงในชุดชิ้นงานการซิงค์สถานที่ตั้งที่สร้างขึ้นให้คุณ ซึ่งคล้ายกับ
ตอนที่คุณทำด้วยตนเองโดยใช้
AssetSetAssetService
คุณไม่จำเป็นต้อง
จัดการชิ้นงานเหล่านั้น เว้นแต่จะต้องการเพิ่มลงในชุดชิ้นงานของกลุ่มตำแหน่งคงที่ด้วยตนเอง
ลูกค้าจะมีชุดชิ้นงานการซิงค์สถานที่ตั้งที่ใช้งานอยู่ได้เพียงชุดเดียวซึ่งมี
(status
ของ
ENABLED
) หากต้องการสร้างชิ้นงานการซิงค์ตำแหน่งประเภทอื่น
ให้นำชิ้นงานที่มีอยู่ออกก่อน
แนบชุดชิ้นงานการซิงค์ตำแหน่งกับลูกค้า
ใช้
CustomerAssetSetService.MutateCustomerAssetSets
เพื่อแนบชุดชิ้นงานการซิงค์สถานที่ตั้งที่ตั้งค่าไว้ในส่วนก่อนหน้ากับลูกค้า
(ไม่บังคับ) สร้างชุดชิ้นงานกลุ่มสถานที่ตั้งและแนบไปกับแคมเปญหรือกลุ่มโฆษณา
คุณต้องมีชุดชิ้นงานกลุ่มสถานที่ตั้งก็ต่อเมื่อต้องการเลือกชิ้นงานสถานที่ตั้งบางส่วน เท่านั้น เนื่องจากแคมเปญและกลุ่มโฆษณารับค่าชิ้นงานสถานที่ตั้งจากระดับลูกค้า
ชุดชิ้นงานกลุ่มสถานที่ตั้งประกอบด้วยชุดย่อยของชิ้นงานสถานที่ตั้งของชุดชิ้นงานการซิงค์ สถานที่ตั้ง คุณสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบไดนามิกได้โดย ใช้ประโยชน์จากฟีเจอร์บางอย่างของ Google Business Profile (เช่น การกรองตามป้ายกำกับ) หรือรหัสเครือและสถานที่ตั้งของเครือ หรือจะสร้างชุดชิ้นงานกลุ่มสถานที่แบบคงที่ก็ได้
- สร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง ชุดชิ้นงานกลุ่มสถานที่ตั้งอาจเป็นแบบไดนามิกหรือแบบคงที่
- แนบชุดชิ้นงานกับแคมเปญหรือกลุ่มโฆษณาตามความต้องการของคุณ
- (ไม่บังคับ) เพิ่มชิ้นงานที่สร้างไว้ก่อนหน้านี้ลงในชุดชิ้นงานกลุ่มสถานที่ตั้งแบบคงที่ที่สร้างขึ้นใหม่
คุณสามารถสร้างชุดชิ้นงานกลุ่มสถานที่ตั้งแบบไดนามิกหรือแบบคงที่หลายชุดสำหรับลูกค้าที่ต้องการ
สร้างชุดชิ้นงานกลุ่มสถานที่ตั้ง
สร้าง 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
เมื่อใช้ 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;
}
}