คุณสามารถใช้ Google Ads API เพื่อนําเข้า Conversion ออฟไลน์ไปยัง Google Ads เพื่อติดตามโฆษณาที่ทําให้เกิดยอดขายในโลกออฟไลน์ เช่น ทางโทรศัพท์หรือผ่านตัวแทนฝ่ายขาย
เพื่อให้ได้รับประโยชน์จากสิทธิประโยชน์ของการนำเข้าข้อมูล Conversion อย่างเต็มที่ เราขอแนะนำให้ใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย ซึ่งใช้ประโยชน์จาก GCLID และข้อมูลที่ได้จากผู้ใช้เพื่อเพิ่มความคงทนและประสิทธิภาพสูงสุด
Conversion ที่ปรับปรุงแล้ว
Conversion ที่ปรับปรุงแล้วช่วยเพิ่มความแม่นยำของการวัด Conversion โดยการเสริม Conversion ด้วยข้อมูล Conversion จากบุคคลที่หนึ่ง เช่น อีเมล หมายเลขโทรศัพท์ และที่อยู่จัดส่ง
Conversion ที่ปรับปรุงแล้วมี 2 ประเภท ดูรายละเอียดเพิ่มเติมได้ที่เกี่ยวกับ Conversion ที่ปรับปรุงแล้ว
ส่วนต่อไปนี้อธิบายวิธีปรับปรุง Conversion ออฟไลน์ ซึ่งเป็นฟีเจอร์ที่เรียกอีกอย่างว่า Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย
Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายคืออะไร
Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายคือการนำเข้า Conversion ออฟไลน์เวอร์ชันที่อัปเกรดแล้ว ซึ่งใช้ข้อมูลที่ได้จากผู้ใช้ เช่น อีเมล เพื่อเสริมข้อมูล Conversion ออฟไลน์ที่นำเข้าเพื่อปรับปรุงความแม่นยำและประสิทธิภาพการเสนอราคา เมื่อคุณนําเข้า Conversion ออฟไลน์ ระบบจะใช้ข้อมูลลูกค้าที่แฮชที่ให้มาเพื่อระบุแหล่งที่มากลับไปยังแคมเปญ Google Ads โดยจับคู่กับข้อมูลเดียวกันที่เก็บรวบรวมในเว็บไซต์ เช่น โฆษณาแบบกรอกฟอร์ม และกับลูกค้าที่ลงชื่อเข้าใช้ซึ่งมีส่วนร่วมกับโฆษณา ดูข้อมูลเพิ่มเติมได้ที่เกี่ยวกับ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย
คุณสามารถใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายได้ 2 วิธี ขึ้นอยู่กับว่าคุณใช้แท็ก Google เพื่อติดตามเหตุการณ์การส่งแบบฟอร์มในหน้าเว็บหรือไม่ เราขอแนะนําให้ใช้แท็ก Google สําหรับ Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขายเพื่อให้ได้ประสิทธิภาพและความเสถียรสูงสุด
- หากคุณเริ่มต้นจากศูนย์ ให้เริ่มจากส่วนข้อกำหนดเบื้องต้น
- หากคุณตั้งค่าการนำเข้า Conversion ออฟไลน์ไว้แล้ว และต้องการอัปเกรดเป็น Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย เราขอแนะนําให้เริ่มต้นด้วยส่วนกําหนดค่าการติดแท็ก
- หากคุณตั้งค่าแท็ก Google แล้ว หรือไม่ได้วางแผนที่จะใช้แท็ก Google และกำลังเริ่มดำเนินการผสานรวม Google Ads API ให้ข้ามไปยังส่วนการติดตั้งใช้งาน API
- หากคุณไม่สามารถนําเข้าข้อมูลที่ได้จากผู้ใช้ หรือใช้การระบุแหล่งที่มาภายนอกสําหรับ Conversion โปรดดูคู่มือการนําเข้า Conversion ออฟไลน์แบบเดิม
ข้อกำหนดเบื้องต้น
ก่อนอื่น ให้ตรวจสอบว่าคุณได้ทำตามขั้นตอนในส่วนการเริ่มต้นใช้งานแล้ว
คุณต้องเลือกใช้ Conversion ที่ปรับปรุงแล้วและยอมรับข้อกำหนดสำหรับข้อมูลลูกค้าก่อนจึงจะใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายได้ คุณยืนยันได้ว่ามีคุณสมบัติตามข้อกำหนดเบื้องต้นเหล่านี้แล้วหรือไม่โดยส่งคำค้นหาต่อไปนี้ไปยังลูกค้า Conversion ของ Google Ads
SELECT
customer.id,
customer.conversion_tracking_setting.accepted_customer_data_terms,
customer.conversion_tracking_setting.enablement_setting,
customer.conversion_tracking_setting.effective_enablement_setting
FROM customer
หาก accepted_customer_data_terms เป็น false หรือหาก enablement_setting
(หรือ effective_enablement_setting เมื่อใช้เครื่องมือวัด Conversion ข้ามบัญชี
) ไม่ใช่ ON ให้ทําตามวิธีการ
ในสร้างการกระทําที่ถือเป็น Conversion ใหม่ เพื่อทําข้อกําหนดเบื้องต้นเหล่านี้ให้เสร็จสมบูรณ์
กำหนดค่าการติดแท็ก
กําหนดค่าแท็ก Google เพื่อเปิดใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายโดยทําตามวิธีการกําหนดการตั้งค่าแท็ก Google หากต้องการ ตั้งค่า Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายโดยใช้ Google Tag Manager ให้ทําตาม วิธีการของ Google Tag Manager
การใช้งาน API
ขั้นตอนโดยรวมสําหรับการนําเข้า Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขายโดยใช้ Google Ads API มีดังนี้
ปรับข้อมูลที่ได้จากผู้ใช้ให้เป็นมาตรฐานและแฮช เช่น อีเมล หมายเลขโทรศัพท์ และที่อยู่จัดส่ง
ป้อนข้อมูลลงในออบเจ็กต์
ClickConversionด้วยข้อมูลที่ได้จากผู้ใช้ที่แปลงเป็นรูปแบบมาตรฐานและแฮชแล้วนําเข้าออบเจ็กต์
ClickConversionไปยัง Google Ads API โดยใช้ConversionUploadServiceดูรายละเอียดเพิ่มเติมได้ที่UploadClickConversions
สรุปสคีมา Request และ ClickConversion
ตารางต่อไปนี้สรุปช่องสําคัญใน UploadClickConversionsRequest และ ClickConversion สําหรับ Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขาย (ดูรายละเอียดช่องทั้งหมดได้ที่ป้อนข้อมูลออบเจ็กต์ ClickConversion และสร้างคําขอ)
| เส้นทางช่อง | ข้อกำหนด | รูปแบบและข้อจำกัด |
|---|---|---|
customer_id |
ต้องระบุ | ตั้งค่าเป็นรหัสลูกค้า Conversion ของ Google Ads (google_ads_conversion_customer ใน customer.conversion_tracking_setting) โดยไม่มีขีดกลาง |
partial_failure |
ต้องระบุ | ต้องตั้งค่าเป็น true เพื่อให้นําเข้า Conversion ที่ถูกต้องและแสดงข้อผิดพลาดระดับแถวใน partial_failure_error |
validate_only |
ไม่บังคับ | เมื่อเป็น true ระบบจะตรวจสอบคำขอโดยไม่นำเข้า Conversion (แสดงข้อผิดพลาดในการตรวจสอบใน partial_failure_error) |
job_id |
ไม่บังคับ | ค่าที่ไม่ใช่ค่าลบ int32 (0 ถึง 2^31 - 1) เพื่อจัดกลุ่มคำขอหลายรายการภายใต้งานเชิงตรรกะเดียวใน job_summaries |
conversions[].conversion_action |
ต้องระบุ | ชื่อทรัพยากร (customers/{conversion_customer_id}/conversionActions/{action_id}) ของการกระทําที่ถือเป็น Conversion ENABLED ที่มี type = UPLOAD_CLICKS |
conversions[].conversion_date_time |
ต้องระบุ | ต้องอยู่หลังเวลาคลิกและมีออฟเซ็ตเขตเวลา: yyyy-mm-dd hh:mm:ss+|-hh:mm (เช่น 2026-06-01 14:30:00-04:00) |
conversions[].conversion_value และ currency_code |
แนะนำ | มูลค่า Conversion ที่เป็นตัวเลข (double) และรหัสสกุลเงิน ISO 4217 ที่มี 3 อักขระ (เช่น USD) |
conversions[].order_id |
แนะนำ | รหัสธุรกรรมที่ไม่ซ้ำกันต่อการกระทำที่ถือเป็น Conversion เพื่อป้องกันการนำเข้าซ้ำและรองรับการปรับในอนาคต |
conversions[].gclid / gbraid / wbraid |
แนะนำให้ใช้หากเป็นไปได้ | ตัวระบุคลิกที่บันทึกจาก URL ของหน้า Landing Page รวมไว้ข้าง user_identifiers เมื่อมีให้ใช้งาน |
conversions[].user_identifiers[] |
จำเป็นสําหรับ Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขาย | ออบเจ็กต์ UserIdentifier 1-5 รายการต่อ Conversion ตั้งค่า user_identifier_source ที่ไม่บังคับ (เช่น FIRST_PARTY) และ hashed_email (ตัดแต่ง แปลงเป็นตัวพิมพ์เล็ก ลบจุดและคำต่อท้าย + ก่อน @ ออกสำหรับ gmail.com และ googlemail.com, เลขฐานสิบหก SHA-256) หรือ hashed_phone_number (รูปแบบ E.164, เลขฐานสิบหก SHA-256) ดูแปลงข้อมูลเป็นรูปแบบมาตรฐานและแฮช ไม่รองรับ address_info |
conversions[].consent.ad_user_data |
แนะนำ | ตั้งค่าเป็น GRANTED หรือ DENIED ใน Consent (ad_personalization รองรับเฉพาะใน OfflineUserDataJobService และ UserDataService) |
conversions[].custom_variables และ external_attribution_data |
อย่าตั้งค่าด้วย user_identifiers |
Conversion ที่มี user_identifiers ต้องไม่ตั้งค่า custom_variables หรือ external_attribution_data มิฉะนั้นจะถูกปฏิเสธ |
ดึงข้อมูลชื่อทรัพยากรการกระทำที่ถือเป็น Conversion
หากต้องการอัปโหลด Conversion คุณต้องระบุชื่อทรัพยากรของ ConversionAction ที่ตั้งค่าไว้ใน Google Ads เพื่อนำเข้า Conversion การคลิก คุณดูชื่อทรัพยากรได้โดยการค้นหาทรัพยากร
conversion_action โดยใช้การค้นหา GAQL
ต่อไปนี้
SELECT
customer.id,
conversion_action.id,
conversion_action.name,
conversion_action.type,
conversion_action.resource_name
FROM conversion_action
WHERE conversion_action.type = 'UPLOAD_CLICKS'
AND conversion_action.status = 'ENABLED'
ทําให้ข้อมูลที่ได้จากผู้ใช้เป็นมาตรฐานและแฮช
ข้อมูลต่อไปนี้ต้องได้รับการแฮชโดยใช้ SHA-256 ก่อนที่จะนำเข้า เพื่อคำนึงถึงความเป็นส่วนตัว
- อีเมล
- หมายเลขโทรศัพท์
- ชื่อ
- นามสกุล
- ที่อยู่
อย่าแฮชข้อมูลต่อไปนี้
- ประเทศ
- รัฐ
- เมือง
- รหัสไปรษณีย์
ก่อนแฮชค่าแต่ละค่าดังกล่าว คุณต้องทำสิ่งต่อไปนี้เพื่อให้ผลลัพธ์การแฮชเป็นมาตรฐาน
- นําช่องว่างขึ้นต้นและต่อท้ายออก
- แปลงข้อความให้เป็นตัวพิมพ์เล็ก
- จัดรูปแบบหมายเลขโทรศัพท์ตามมาตรฐาน E.164
การจัดรูปแบบอีเมลสำหรับ Conversion ที่ปรับปรุงแล้ว
หากต้องการให้ Conversion ที่ปรับปรุงแล้วมีอัตราการจับคู่สูงสุด คุณต้องจัดรูปแบบและแฮชอีเมลอย่างถูกต้องโดยทำตามขั้นตอนต่อไปนี้
ใช้การแปลงเป็นรูปแบบมาตรฐาน (อีเมลทั้งหมด)
- นำช่องว่าง ASCII ขึ้นต้นและต่อท้ายออก
- แปลงอักขระทั้งหมดในอีเมลเป็นตัวพิมพ์เล็ก
ใช้การแปลงเป็นรูปแบบมาตรฐานเฉพาะโดเมน (
gmail.comและgooglemail.comเท่านั้น):- หลังจากเปลี่ยนอีเมลเป็นตัวพิมพ์เล็กแล้ว ให้ตรวจสอบว่าโดเมน (หลังสัญลักษณ์
@) เป็นgmail.comหรือgooglemail.com - นำจุด (
.) ออก: นำอักขระจุดทั้งหมดออกจากส่วนชื่อผู้ใช้ (ก่อนสัญลักษณ์@) - นำคำต่อท้ายเครื่องหมายบวก (
+) ออก: นำเครื่องหมายบวก (+) ตัวแรกและอักขระที่ตามมาทั้งหมดออกจนถึงสัญลักษณ์@จากส่วนชื่อผู้ใช้- ตัวอย่าง:
Jane.Doe+Shopping@googlemail.comจะกลายเป็นjane.doe+shopping@googlemail.com(ตัวพิมพ์เล็ก) ก่อน แล้วจึงกลายเป็นjanedoe@googlemail.com(กฎของ Gmail และ Googlemail)
- ตัวอย่าง:
- โดเมนอื่นๆ: สำหรับโดเมนใดๆ ที่ไม่ใช่
gmail.comหรือgooglemail.comอย่านำจุดหรือคำต่อท้ายเครื่องหมายบวกออกจากชื่อผู้ใช้ ใช้เฉพาะการปรับมาตรฐาน (ตัดช่องว่างและแปลงเป็นตัวพิมพ์เล็ก)- ตัวอย่าง:
user.name+NYC@Example.comจะได้รับการแปลงเป็นuser.name+nyc@example.com
- ตัวอย่าง:
- หลังจากเปลี่ยนอีเมลเป็นตัวพิมพ์เล็กแล้ว ให้ตรวจสอบว่าโดเมน (หลังสัญลักษณ์
แฮชอีเมลที่แปลงเป็นรูปแบบมาตรฐานแล้ว
- เข้ารหัสสตริงอีเมลที่ปรับมาตรฐานเป็นไบต์ UTF-8
- แฮชไบต์ UTF-8 โดยใช้อัลกอริทึม SHA-256
- จัดรูปแบบไดเจสต์ที่ได้เป็นสตริงเลขฐาน 16 ตัวพิมพ์เล็ก (64 อักขระ)
import hashlib
import re
def normalize_and_hash_email(email: str) -> str:
"""Normalizes and SHA-256 hashes an email address for enhanced conversions."""
normalized = email.strip().lower()
parts = normalized.split("@")
if len(parts) != 2:
raise ValueError("Invalid email address format.")
username, domain = parts
if domain in ("gmail.com", "googlemail.com"):
username = username.replace(".", "")
username = re.sub(r"\+.*$", "", username)
normalized = f"{username}@{domain}"
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()
ตัวอย่างโค้ด
ตัวอย่างนี้แสดงวิธีปรับข้อมูลที่ได้จากผู้ใช้ให้เป็นมาตรฐานและแฮช
Java
private String normalizeAndHash(MessageDigest digest, String s) throws UnsupportedEncodingException { // Normalizes by first converting all characters to lowercase, then trimming spaces. String normalized = s.toLowerCase(); // Removes leading, trailing, and intermediate spaces. normalized = normalized.replaceAll("\\s+", ""); // Hashes the normalized string using the hashing algorithm. byte[] hash = digest.digest(normalized.getBytes("UTF-8")); StringBuilder result = new StringBuilder(); for (byte b : hash) { result.append(String.format("%02x", b)); } return result.toString(); } /** * Returns the result of normalizing and hashing an email address. For this use case, Google Ads * requires removal of any '.' characters or trailing '+' and characters that follow it from the * username portion of the email address if the domain is {@code gmail.com} or {@code * googlemail.com}. * * @param digest the digest to use to hash the normalized string. * @param emailAddress the email address to normalize and hash. */ private String normalizeAndHashEmailAddress(MessageDigest digest, String emailAddress) throws UnsupportedEncodingException { // Removes all whitespace (leading, trailing, and intermediate) from the email address. String normalizedEmail = emailAddress.toLowerCase().replaceAll("\\s+", ""); String[] emailParts = normalizedEmail.split("@", 2); if (emailParts.length == 2 && emailParts[1].matches("^(gmail|googlemail)\\.com$")) { // Removes any '.' characters from the portion of the email address before the domain if the // domain is gmail.com or googlemail.com. emailParts[0] = emailParts[0].replaceAll("\\.", ""); // Removes any '+' and all characters that follow it from the portion of the email address // before the domain if the domain is gmail.com or googlemail.com. emailParts[0] = emailParts[0].replaceAll("\\+.*", ""); normalizedEmail = String.format("%s@%s", emailParts[0], emailParts[1]); } return normalizeAndHash(digest, normalizedEmail); } /** * Returns the result of normalizing and hashing a phone number. For this use case, Google Ads * requires phone numbers to be in E.164 format. * * @param digest the digest to use to hash the normalized string. * @param phoneNumber the phone number to normalize and hash. */ private String normalizeAndHashPhoneNumber(MessageDigest digest, String phoneNumber) throws UnsupportedEncodingException { // Removes non-digit characters and prepends a leading '+' sign. String digitsOnly = phoneNumber.replaceAll("[^0-9]", ""); String formattedPhone = "+" + digitsOnly; if (!formattedPhone.matches("^\\+[1-9]\\d{6,14}$")) { throw new IllegalArgumentException("Phone number must be in E.164 format: " + phoneNumber); } return normalizeAndHash(digest, formattedPhone); }
C#
/// <summary> /// Normalizes the email address and hashes it. For this use case, Google Ads requires /// removal of any '.' characters preceding <code>gmail.com</code> or /// <code>googlemail.com</code>. /// </summary> /// <param name="emailAddress">The email address.</param> /// <returns>The hash code.</returns> private string NormalizeAndHashEmailAddress(string emailAddress) { string normalizedEmail = emailAddress.ToLower(); string[] emailParts = normalizedEmail.Split('@'); if (emailParts.Length > 1 && (emailParts[1] == "gmail.com" || emailParts[1] == "googlemail.com")) { // Removes any '.' characters from the portion of the email address before // the domain if the domain is gmail.com or googlemail.com. emailParts[0] = emailParts[0].Replace(".", ""); normalizedEmail = $"{emailParts[0]}@{emailParts[1]}"; } return NormalizeAndHash(normalizedEmail); } /// <summary> /// Normalizes and hashes a string value. /// </summary> /// <param name="value">The value to normalize and hash.</param> /// <returns>The normalized and hashed value.</returns> private static string NormalizeAndHash(string value) { return ToSha256String(digest, ToNormalizedValue(value)); } /// <summary> /// Hash a string value using SHA-256 hashing algorithm. /// </summary> /// <param name="digest">Provides the algorithm for SHA-256.</param> /// <param name="value">The string value (e.g. an email address) to hash.</param> /// <returns>The hashed value.</returns> private static string ToSha256String(SHA256 digest, string value) { byte[] digestBytes = digest.ComputeHash(Encoding.UTF8.GetBytes(value)); // Convert the byte array into an unhyphenated hexadecimal string. return BitConverter.ToString(digestBytes).Replace("-", string.Empty); } /// <summary> /// Removes leading and trailing whitespace and converts all characters to /// lower case. /// </summary> /// <param name="value">The value to normalize.</param> /// <returns>The normalized value.</returns> private static string ToNormalizedValue(string value) { return value.Trim().ToLower(); }
PHP
private static function normalizeAndHash(string $hashAlgorithm, string $value): string { // Normalizes by first converting all characters to lowercase, then trimming spaces. $normalized = strtolower($value); // Removes leading, trailing, and intermediate spaces. $normalized = str_replace(' ', '', $normalized); return hash($hashAlgorithm, strtolower(trim($normalized))); } /** * Returns the result of normalizing and hashing an email address. For this use case, Google * Ads requires removal of any '.' characters preceding "gmail.com" or "googlemail.com". * * @param string $hashAlgorithm the hash algorithm to use * @param string $emailAddress the email address to normalize and hash * @return string the normalized and hashed email address */ private static function normalizeAndHashEmailAddress( string $hashAlgorithm, string $emailAddress ): string { $normalizedEmail = strtolower($emailAddress); $emailParts = explode("@", $normalizedEmail); if ( count($emailParts) > 1 && preg_match('/^(gmail|googlemail)\.com\s*/', $emailParts[1]) ) { // Removes any '.' characters from the portion of the email address before the domain // if the domain is gmail.com or googlemail.com. $emailParts[0] = str_replace(".", "", $emailParts[0]); $normalizedEmail = sprintf('%s@%s', $emailParts[0], $emailParts[1]); } return self::normalizeAndHash($hashAlgorithm, $normalizedEmail); }
Python
def normalize_and_hash_email_address(email_address: str) -> str: """Returns the result of normalizing and hashing an email address. For this use case, Google Ads requires removal of any '.' characters preceding "gmail.com" or "googlemail.com" Args: email_address: An email address to normalize. Returns: A normalized (lowercase, removed whitespace) and SHA-265 hashed string. """ normalized_email: str = email_address.strip().lower() email_parts: list[str] = normalized_email.split("@") # Check that there are at least two segments if len(email_parts) > 1: # Removes any '.' and '+' characters from the portion of the email address # before the domain chars_to_remove = ".+" translation_table = str.maketrans("", "", chars_to_remove) email_parts[0] = email_parts[0].translate(translation_table) normalized_email = "@".join(email_parts) return normalize_and_hash(normalized_email) def normalize_and_hash(s: str) -> str: """Normalizes and hashes a string with SHA-256. Private customer data must be hashed during upload, as described at: https://support.google.com/google-ads/answer/7474263 Args: s: The string to perform this operation on. Returns: A normalized (lowercase, removed whitespace) and SHA-256 hashed string. """ return hashlib.sha256(s.strip().lower().encode()).hexdigest()
Ruby
# Returns the result of normalizing and then hashing the string using the # provided digest. Private customer data must be hashed during upload, as # described at https://support.google.com/google-ads/answer/7474263. def normalize_and_hash(str) # Remove leading and trailing whitespace and ensure all letters are lowercase # before hashing. Digest::SHA256.hexdigest(str.strip.downcase) end # Returns the result of normalizing and hashing an email address. For this use # case, Google Ads requires removal of any '.' characters preceding 'gmail.com' # or 'googlemail.com'. def normalize_and_hash_email(email) email_parts = email.downcase.split("@") # Removes any '.' characters from the portion of the email address before the # domain if the domain is gmail.com or googlemail.com. if email_parts.last =~ /^(gmail|googlemail)\.com\s*/ email_parts[0] = email_parts[0].gsub('.', '') end normalize_and_hash(email_parts.join('@')) end
Perl
sub normalize_and_hash { my $value = shift; # Removes leading, trailing, and intermediate spaces. $value =~ s/\s+//g; return sha256_hex(lc $value); } # Returns the result of normalizing and hashing an email address. For this use # case, Google Ads requires removal of any '.' characters preceding 'gmail.com' # or 'googlemail.com'. sub normalize_and_hash_email_address { my $email_address = shift; my $normalized_email = lc $email_address; my @email_parts = split('@', $normalized_email); if (scalar @email_parts > 1 && $email_parts[1] =~ /^(gmail|googlemail)\.com\s*/) { # Remove any '.' characters from the portion of the email address before the # domain if the domain is 'gmail.com' or 'googlemail.com'. $email_parts[0] =~ s/\.//g; $normalized_email = sprintf '%s@%s', $email_parts[0], $email_parts[1]; } return normalize_and_hash($normalized_email); }
curl
ป้อนข้อมูลออบเจ็กต์ ClickConversion
ออบเจ็กต์ ClickConversion ใน UploadClickConversionsRequest แสดงถึงชุด Conversion ที่คุณต้องการนำเข้า
โปรดคำนึงถึงรายละเอียดต่อไปนี้เมื่อสร้างออบเจ็กต์ ClickConversion
gclidGCLID คือตัวระบุที่ได้จากพารามิเตอร์ของ URL เมื่อผู้ใช้คลิกโฆษณาและไปยังเว็บไซต์ของคุณ
gbraidgbraidคือพารามิเตอร์ของ URL ที่แสดงเมื่อผู้ใช้คลิกโฆษณาบนเว็บและระบบนำผู้ใช้ไปยังแอป iOS ของคุณwbraidwbraidคือพารามิเตอร์ของ URL ที่แสดงเมื่อผู้ใช้คลิกโฆษณาในแอป iOS และระบบนำผู้ใช้ไปยังหน้าเว็บของคุณcart_dataมีรายละเอียดระดับสินค้าเกี่ยวกับ Conversion คุณต้องระบุข้อมูลในช่อง
cart_dataเพื่อรายงานข้อมูลตะกร้าสินค้า เช่น สินค้าที่ซื้อ ราคา และจำนวนใน UI ของ Google Ads ดูคำจำกัดความของออบเจ็กต์CartDataสำหรับโครงสร้างที่จำเป็น และดูข้อมูลเพิ่มเติมได้ที่ เกี่ยวกับ Conversion จากข้อมูลรถเข็นช็อปปิ้งuser_identifiersเมื่อใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย คุณต้องป้อนข้อมูลที่ได้จากผู้ใช้ซึ่งผ่านการปรับมาตรฐานและแฮชแล้วในช่อง
user_identifiersหากมีตัวระบุผู้ใช้หลายรายการ ให้สร้างUserIdentifierแยกต่างหากสำหรับแต่ละรายการ โดยมีตัวระบุได้สูงสุด 5 รายการconversion_date_timeวันที่และเวลาที่เกิด Conversion
ค่าต้องระบุเขตเวลา และรูปแบบต้องเป็น
yyyy-mm-dd HH:mm:ss+|-HH:mmเช่น2022-01-01 19:32:45-05:00(ไม่สนใจเวลาออมแสง)เขตเวลาอาจเป็นค่าใดก็ได้ที่ถูกต้อง โดยไม่จำเป็นต้องตรงกับเขตเวลาของบัญชี อย่างไรก็ตาม หากคุณวางแผนที่จะเปรียบเทียบข้อมูล Conversion ที่นำเข้ากับข้อมูลใน UI ของ Google Ads เราขอแนะนำให้ใช้เขตเวลาเดียวกับบัญชี Google Ads เพื่อให้จำนวน Conversion ตรงกัน ดูรายละเอียดและตัวอย่างเพิ่มเติมได้ในเตรียมข้อมูลสำหรับการนำเข้า และดูรายการรหัสเขตเวลาที่ถูกต้องได้ที่รหัสและรูปแบบ
conversion_actionชื่อทรัพยากรของ
ConversionActionสําหรับ Conversion ออฟไลน์การกระทําที่ถือเป็น Conversion ต้องมี
typeเป็นUPLOAD_CLICKSและต้องอยู่ในลูกค้า Conversion ของ Google Ads ของบัญชี Google Ads ที่เชื่อมโยงกับการคลิกconversion_valueมูลค่าของ Conversion
currency_codeรหัสสกุลเงินของ
conversion_valueconsentเราขอแนะนำให้คุณระบุข้อมูลในช่อง
consentของออบเจ็กต์ClickConversionหากไม่ได้ตั้งค่าไว้ ระบบอาจระบุแหล่งที่มาของ Conversion ไม่ได้order_idหรือที่เรียกว่ารหัสธุรกรรมสำหรับ Conversion คุณจะกรอกข้อมูลในฟิลด์นี้หรือไม่ก็ได้ แต่เราขอแนะนำให้ทำ เนื่องจากจะช่วยให้อ้างอิง Conversion ที่นำเข้าเมื่อทำการปรับได้ง่ายขึ้น หากตั้งค่าไว้ระหว่างการนำเข้า คุณต้องใช้ค่าดังกล่าวสำหรับการปรับทั้งหมด ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีใช้รหัสธุรกรรมเพื่อลดจำนวน Conversion ที่ซ้ำกันได้ที่หัวข้อใช้รหัสธุรกรรมเพื่อลดจำนวน Conversion ที่ซ้ำกัน
custom_variablesค่าของตัวแปร Conversion ที่กำหนดเอง Google Ads ไม่รองรับตัวแปร Conversion ที่กำหนดเองร่วมกับ
wbraidหรือgbraidconversion_environmentระบุสภาพแวดล้อมที่บันทึก Conversion นี้ เช่น
APPหรือWEB
session_attributes_encodedและsession_attributes_key_value_pairsแอตทริบิวต์เซสชันแสดงถึงตัวระบุแบบรวมที่ใช้สำหรับการระบุแหล่งที่มาของ Conversion ซึ่งจะทำงานนอกเหนือจาก GCLID และพารามิเตอร์ของ URL (เช่น GBRAID) รวมถึงข้อมูลที่ได้จากผู้ใช้ ซึ่งเป็นหัวใจสำคัญของ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย คุณนําเข้าแอตทริบิวต์เซสชันได้ 2 วิธี ได้แก่ การระบุโทเค็นที่เข้ารหัสซึ่งสร้างโดยโค้ด JavaScript ในเบราว์เซอร์ หรือการระบุคู่คีย์-ค่าแต่ละคู่สําหรับตัวระบุแต่ละรายการ
เราขอแนะนําให้นําเข้าตัวระบุการคลิก ข้อมูลที่ได้จากผู้ใช้ และแอตทริบิวต์เซสชันพร้อมกับ Conversion ทั้งหมด (หากเป็นไปได้) เพื่อเพิ่มประสิทธิภาพของแคมเปญให้สูงสุด
Java
// Sets one of the sessionAttributesEncoded or sessionAttributesKeyValuePairs if either is // provided. The session attribute fields are only available to allowlisted users. // To include these fields in conversion imports, upgrade to the Data Manager API. if (rawRecord.containsKey("sessionAttributesEncoded")) { clickConversionBuilder.setSessionAttributesEncoded( ByteString.copyFromUtf8(rawRecord.get("sessionAttributesEncoded"))); } else if (rawRecord.containsKey("sessionAttributesMap")) { List<String> pairings = Arrays.stream(rawRecord.get("sessionAttributesMap").split(" ")) .map(String::trim) .collect(Collectors.toList()); SessionAttributesKeyValuePairs.Builder sessionAttributePairs = SessionAttributesKeyValuePairs.newBuilder(); for (String pair : pairings) { String[] parts = pair.split("=", 2); if (parts.length != 2) { throw new IllegalArgumentException( "Failed to read the sessionAttributesMap. SessionAttributesMap must use a" + " space-delimited list of session attribute key value pairs. Each pair should" + " be separated by an equal sign, for example: 'gad_campaignid=12345" + " gad_source=1'"); } sessionAttributePairs.addKeyValuePairs( SessionAttributeKeyValuePair.newBuilder() .setSessionAttributeKey(parts[0]) .setSessionAttributeValue(parts[1]) .build()); } clickConversionBuilder.setSessionAttributesKeyValuePairs(sessionAttributePairs.build()); }
C#
// The session attribute fields are only available to allowlisted users. To // include these fields in conversion imports, upgrade to the Data Manager API. if (!string.IsNullOrEmpty(sessionAttributesEncoded)) { clickConversion.SessionAttributesEncoded = ByteString.CopyFrom(sessionAttributesEncoded, Encoding.Unicode); } else if (!string.IsNullOrEmpty(sessionAttributes)) { IEnumerable<SessionAttributeKeyValuePair> parsedSessionAttributes = sessionAttributes.Split(';').Select(pair => { string[] split = pair.Split('='); return new SessionAttributeKeyValuePair() { SessionAttributeKey = split[0], SessionAttributeValue = split[1] }; }); clickConversion.SessionAttributesKeyValuePairs = new SessionAttributesKeyValuePairs(); clickConversion.SessionAttributesKeyValuePairs.KeyValuePairs .AddRange(parsedSessionAttributes); }
PHP
This example is not yet available in PHP; you can take a look at the other languages.
Python
# Set one of the session_attributes_encoded or # session_attributes_key_value_pairs fields if either are provided. # The session attribute fields are only available to allowlisted users. # To include these fields in conversion imports, upgrade to the Data Manager API. if session_attributes_encoded: click_conversion.session_attributes_encoded = session_attributes_encoded elif session_attributes_dict: for key, value in session_attributes_dict.items(): pair: SessionAttributeKeyValuePair = client.get_type( "SessionAttributeKeyValuePair" ) pair.session_attribute_key = key pair.session_attribute_value = value click_conversion.session_attributes_key_value_pairs.key_value_pairs.append( pair )
Ruby
# Set one of the session_attributes_encoded or # session_attributes_key_value_pairs fields if either are provided. # The session attribute fields are only available to allowlisted users. # To include these fields in conversion imports, upgrade to the Data Manager API. if session_attributes_encoded != nil cc.class.module_eval { attr_accessor :session_attributes_encoded} cc.session_attributes_encoded = session_attributes_encoded elsif session_attributes_hash != nil # Add new attribute to click conversion object cc.class.module_eval { attr_accessor :session_attributes_key_value_pairs} cc.session_attributes_key_value_pairs = ::Google::Ads::GoogleAds::V19::Services::SessionAttributesKeyValuePairs.new # Loop thru inputted session_attributes_hash to populate session_attributes_key_value_pairs session_attributes_hash.each do |key, value| pair = ::Google::Ads::GoogleAds::V19::Services::SessionAttributeKeyValuePair.new pair.session_attribute_key = key pair.session_attribute_value = value cc.session_attributes_key_value_pairs.key_value_pairs << pair end end
Perl
# Set one of the session_attributes_encoded or session_attributes_key_value_pairs # fields if either are provided. if (defined $session_attributes_encoded) { $click_conversion->{sessionAttributesEncoded} = $session_attributes_encoded; } elsif (defined $session_attributes_hash) { while (my ($key, $value) = each %$session_attributes_hash) { my $pair = Google::Ads::GoogleAds::V26::Services::ConversionUploadService::SessionAttributeKeyValuePair ->new({sessionAttributeKey => $key, sessionAttributeValue => $value}); push @{$click_conversion->{sessionAttributesKeyValuePairs}{keyValuePairs} }, $pair; } }
curl
user_ip_addressที่อยู่ IP ของลูกค้าเมื่อมาถึงหน้า Landing Page หลังจากคลิกโฆษณาและก่อนเหตุการณ์ Conversion ซึ่งเป็นที่อยู่ IP ของอุปกรณ์ของลูกค้า ไม่ใช่เซิร์ฟเวอร์ของผู้ลงโฆษณา
ช่องนี้เป็นสตริงที่แสดงที่อยู่ IP ในรูปแบบ IPv4 หรือ IPv6 เช่น
- IPv4:
"192.0.2.0" - IPv6:
"2001:0DB8:1234:5678:9999:1111:0000:0001"
- IPv4:
ตัวอย่างโค้ด
ตัวอย่างนี้แสดงวิธีตั้งค่าข้อมูลที่ได้จากผู้ใช้ซึ่งเป็นมาตรฐานและแฮชแล้วในออบเจ็กต์ ClickConversion
Java
// Creates an empty builder for constructing the click conversion. ClickConversion.Builder clickConversionBuilder = ClickConversion.newBuilder(); // Extracts user email and phone from the raw data, normalizes and hashes it, then wraps it in // UserIdentifier objects. // Creates a separate UserIdentifier object for each. The data in this example is hardcoded, but // in your application you might read the raw data from an input file. // IMPORTANT: Since the identifier attribute of UserIdentifier // (https://developers.google.com/google-ads/api/reference/rpc/latest/UserIdentifier) is a // oneof // (https://protobuf.dev/programming-guides/proto3/#oneof-features), you must set only ONE of // hashedEmail, hashedPhoneNumber, mobileId, thirdPartyUserId, or addressInfo. Setting more // than one of these attributes on the same UserIdentifier will clear all the other members // of the oneof. For example, the following code is INCORRECT and will result in a // UserIdentifier with ONLY a hashedPhoneNumber. // // UserIdentifier incorrectlyPopulatedUserIdentifier = // UserIdentifier.newBuilder() // .setHashedEmail("...") // .setHashedPhoneNumber("...") // .build(); ImmutableMap.Builder<String, String> rawRecordBuilder = ImmutableMap.<String, String>builder() .put("email", "alex.2+myalias@gmail.com") // Phone number to be converted to E.164 format, with a leading '+' as required. .put("phone", "+1 (800) 555-0102") // This example lets you put conversion details as arguments, but in reality you might // store this data alongside other user data, so we include it in this sample user // record. .put("conversionActionId", Long.toString(conversionActionId)) .put("conversionDateTime", conversionDateTime) .put("conversionValue", Double.toString(conversionValue)) .put("currencyCode", "USD"); // Adds entries for the optional fields. if (orderId != null) { rawRecordBuilder.put("orderId", orderId); } if (gclid != null) { rawRecordBuilder.put("gclid", gclid); } if (adUserDataConsent != null) { rawRecordBuilder.put("adUserDataConsent", adUserDataConsent.name()); } if (sessionAttributesEncoded != null) { rawRecordBuilder.put("sessionAttributesEncoded", sessionAttributesEncoded); } if (sessionAttributesMap != null) { rawRecordBuilder.put("sessionAttributesMap", sessionAttributesMap); } // Builds the map representing the record. Map<String, String> rawRecord = rawRecordBuilder.build(); // Creates a SHA256 message digest for hashing user identifiers in a privacy-safe way, as // described at https://support.google.com/google-ads/answer/9888656. MessageDigest sha256Digest = MessageDigest.getInstance("SHA-256"); // Creates a list for the user identifiers. List<UserIdentifier> userIdentifiers = new ArrayList<>(); // Creates a user identifier using the hashed email address, using the normalize and hash method // specifically for email addresses. UserIdentifier emailIdentifier = UserIdentifier.newBuilder() // Optional: specify the user identifier source. .setUserIdentifierSource(UserIdentifierSource.FIRST_PARTY) // Uses the normalize and hash method specifically for email addresses. .setHashedEmail(normalizeAndHashEmailAddress(sha256Digest, rawRecord.get("email"))) .build(); userIdentifiers.add(emailIdentifier); // Creates a user identifier using normalized and hashed phone info. UserIdentifier hashedPhoneNumberIdentifier = UserIdentifier.newBuilder() .setHashedPhoneNumber(normalizeAndHashPhoneNumber(sha256Digest, rawRecord.get("phone"))) .build(); // Adds the hashed phone number identifier to the UserData object's list. userIdentifiers.add(hashedPhoneNumberIdentifier); // Adds the user identifiers to the conversion. clickConversionBuilder.addAllUserIdentifiers(userIdentifiers);
C#
// Adds a user identifier using the hashed email address, using the normalize // and hash method specifically for email addresses. clickConversion.UserIdentifiers.Add(new UserIdentifier() { HashedEmail = NormalizeAndHashEmailAddress("alex.2@example.com"), // Optional: Specifies the user identifier source. UserIdentifierSource = UserIdentifierSource.FirstParty }); // Adds a user identifier using normalized and hashed phone info. clickConversion.UserIdentifiers.Add(new UserIdentifier() { HashedPhoneNumber = NormalizeAndHash("+1 800 5550102"), // Optional: Specifies the user identifier source. UserIdentifierSource = UserIdentifierSource.FirstParty }); // Adds a user identifier with all the required mailing address elements. clickConversion.UserIdentifiers.Add(new UserIdentifier() { AddressInfo = new OfflineUserAddressInfo() { // FirstName and LastName must be normalized and hashed. HashedFirstName = NormalizeAndHash("Alex"), HashedLastName = NormalizeAndHash("Quinn"), // CountryCode and PostalCode are sent in plain text. CountryCode = "US", PostalCode = "94045" } });
PHP
// Creates a click conversion with the specified attributes. $clickConversion = new ClickConversion(); // Extract user email and phone from the raw data, normalize and hash it, then wrap it in // UserIdentifier objects. Creates a separate UserIdentifier object for each. // The data in this example is hardcoded, but in your application you might read the raw // data from an input file. // IMPORTANT: Since the identifier attribute of UserIdentifier // (https://developers.google.com/google-ads/api/reference/rpc/latest/UserIdentifier) is a // oneof // (https://protobuf.dev/programming-guides/proto3/#oneof-features), you must set only ONE // of hashedEmail, hashedPhoneNumber, mobileId, thirdPartyUserId, or addressInfo. Setting // more than one of these attributes on the same UserIdentifier will clear all the other // members of the oneof. For example, the following code is INCORRECT and will result in a // UserIdentifier with ONLY a hashedPhoneNumber. // // $incorrectlyPopulatedUserIdentifier = new UserIdentifier([ // 'hashed_email' => '...', // 'hashed_phone_number' => '...' // ]); $rawRecord = [ // Email address that includes a period (.) before the Gmail domain. 'email' => 'alex.2@example.com', // Phone number to be converted to E.164 format, with a leading '+' as required. 'phone' => '+1 800 5550102', // This example lets you input conversion details as arguments, but in reality you might // store this data alongside other user data, so we include it in this sample user // record. 'orderId' => $orderId, 'gclid' => $gclid, 'conversionActionId' => $conversionActionId, 'conversionDateTime' => $conversionDateTime, 'conversionValue' => $conversionValue, 'currencyCode' => 'USD', 'adUserDataConsent' => $adUserDataConsent, 'sessionAttributesEncoded' => $sessionAttributesEncoded, 'sessionAttributesDict' => $sessionAttributesDict ]; // Creates a list for the user identifiers. $userIdentifiers = []; // Uses the SHA-256 hash algorithm for hashing user identifiers in a privacy-safe way, as // described at https://support.google.com/google-ads/answer/9888656. $hashAlgorithm = "sha256"; // Creates a user identifier using the hashed email address, using the normalize and hash // method specifically for email addresses. $emailIdentifier = new UserIdentifier( [ // Uses the normalize and hash method specifically for email addresses. 'hashed_email' => self::normalizeAndHashEmailAddress( $hashAlgorithm, $rawRecord['email'] ), // Optional: Specifies the user identifier source. 'user_identifier_source' => UserIdentifierSource::FIRST_PARTY ] ); $userIdentifiers[] = $emailIdentifier; // Checks if the record has a phone number, and if so, adds a UserIdentifier for it. if (array_key_exists('phone', $rawRecord)) { $hashedPhoneNumberIdentifier = new UserIdentifier( [ 'hashed_phone_number' => self::normalizeAndHash( $hashAlgorithm, $rawRecord['phone'], true ) ] ); // Adds the hashed email identifier to the user identifiers list. $userIdentifiers[] = $hashedPhoneNumberIdentifier; } // Adds the user identifiers to the conversion. $clickConversion->setUserIdentifiers($userIdentifiers);
Python
# Extract user email and phone from the raw data, normalize and hash it, # then wrap it in UserIdentifier objects. Create a separate UserIdentifier # object for each. The data in this example is hardcoded, but in your # application you might read the raw data from an input file. # IMPORTANT: Since the identifier attribute of UserIdentifier # (https://developers.google.com/google-ads/api/reference/rpc/latest/UserIdentifier) # is a oneof # (https://protobuf.dev/programming-guides/proto3/#oneof-features), you must # set only ONE of hashed_email, hashed_phone_number, mobile_id, # third_party_user_id, or address_info. Setting more than one of these # attributes on the same UserIdentifier will clear all the other members of # the oneof. For example, the following code is INCORRECT and will result in # a UserIdentifier with ONLY a hashed_phone_number: # # incorrectly_populated_user_identifier = client.get_type("UserIdentifier") # incorrectly_populated_user_identifier.hashed_email = "..."" # incorrectly_populated_user_identifier.hashed_phone_number = "..."" raw_record: Dict[str, Union[str, float]] = { # Email address that includes a period (.) before the Gmail domain. "email": "alex.2@example.com", # Phone number to be converted to E.164 format, with a leading '+' as # required. "phone": "+1 800 5550102", # This example lets you input conversion details as arguments, # but in reality you might store this data alongside other user data, # so we include it in this sample user record. "order_id": order_id, "gclid": gclid, "conversion_action_id": conversion_action_id, "conversion_date_time": conversion_date_time, "conversion_value": conversion_value, "currency_code": "USD", "ad_user_data_consent": ad_user_data_consent, } # Constructs the click conversion. click_conversion: ClickConversion = client.get_type("ClickConversion") # Creates a user identifier using the hashed email address, using the # normalize and hash method specifically for email addresses. email_identifier: UserIdentifier = client.get_type("UserIdentifier") # Optional: Specifies the user identifier source. email_identifier.user_identifier_source = ( client.enums.UserIdentifierSourceEnum.FIRST_PARTY ) # Uses the normalize and hash method specifically for email addresses. email_identifier.hashed_email = normalize_and_hash_email_address( raw_record["email"] ) # Adds the user identifier to the conversion. click_conversion.user_identifiers.append(email_identifier) # Checks if the record has a phone number, and if so, adds a UserIdentifier # for it. if raw_record.get("phone") is not None: phone_identifier: UserIdentifier = client.get_type("UserIdentifier") phone_identifier.hashed_phone_number = normalize_and_hash( raw_record["phone"] ) # Adds the phone identifier to the conversion adjustment. click_conversion.user_identifiers.append(phone_identifier)
Ruby
# Extract user email and phone from the raw data, normalize and hash it, # then wrap it in UserIdentifier objects. Create a separate UserIdentifier # object for each. The data in this example is hardcoded, but in your # application you might read the raw data from an input file. # IMPORTANT: Since the identifier attribute of UserIdentifier # (https://developers.google.com/google-ads/api/reference/rpc/latest/UserIdentifier) # is a oneof # (https://protobuf.dev/programming-guides/proto3/#oneof-features), you must # set only ONE of hashed_email, hashed_phone_number, mobile_id, # third_party_user_id, or address_info. Setting more than one of these # attributes on the same UserIdentifier will clear all the other members of # the oneof. For example, the following code is INCORRECT and will result in # a UserIdentifier with ONLY a hashed_phone_number: # # incorrectly_populated_user_identifier.hashed_email = "..."" # incorrectly_populated_user_identifier.hashed_phone_number = "..."" raw_record = { # Email address that includes a period (.) before the Gmail domain. "email" => "alex.2@example.com", # Phone number to be converted to E.164 format, with a leading '+' as # required. "phone" => "+1 800 5550102", # This example lets you input conversion details as arguments, # but in reality you might store this data alongside other user data, # so we include it in this sample user record. "order_id" => order_id, "gclid" => gclid, "conversion_action_id" => conversion_action_id, "conversion_date_time" => conversion_date_time, "conversion_value" => conversion_value, "currency_code" => "USD", "ad_user_data_consent" => ad_user_data_consent, "session_attributes_encoded" => session_attributes_encoded, "session_attributes_hash" => session_attributes_hash } click_conversion = client.resource.click_conversion do |cc| cc.conversion_action = client.path.conversion_action(customer_id, conversion_action_id) cc.conversion_date_time = conversion_date_time cc.conversion_value = conversion_value.to_f cc.currency_code = 'USD' unless order_id.nil? cc.order_id = order_id end unless raw_record["gclid"].nil? cc.gclid = gclid end # Specifies whether user consent was obtained for the data you are # uploading. For more details, see: # https://www.google.com/about/company/user-consent-policy unless raw_record["ad_user_data_consent"].nil? cc.consent = client.resource.consent do |c| c.ad_user_data = ad_user_data_consent end end # Set one of the session_attributes_encoded or # session_attributes_key_value_pairs fields if either are provided. # The session attribute fields are only available to allowlisted users. # To include these fields in conversion imports, upgrade to the Data Manager API. if session_attributes_encoded != nil cc.class.module_eval { attr_accessor :session_attributes_encoded} cc.session_attributes_encoded = session_attributes_encoded elsif session_attributes_hash != nil # Add new attribute to click conversion object cc.class.module_eval { attr_accessor :session_attributes_key_value_pairs} cc.session_attributes_key_value_pairs = ::Google::Ads::GoogleAds::V19::Services::SessionAttributesKeyValuePairs.new # Loop thru inputted session_attributes_hash to populate session_attributes_key_value_pairs session_attributes_hash.each do |key, value| pair = ::Google::Ads::GoogleAds::V19::Services::SessionAttributeKeyValuePair.new pair.session_attribute_key = key pair.session_attribute_value = value cc.session_attributes_key_value_pairs.key_value_pairs << pair end end # Creates a user identifier using the hashed email address, using the # normalize and hash method specifically for email addresses. # If using a phone number, use the normalize_and_hash method instead. cc.user_identifiers << client.resource.user_identifier do |ui| ui.hashed_email = normalize_and_hash_email(raw_record["email"]) # Optional: Specifies the user identifier source. ui.user_identifier_source = :FIRST_PARTY end # Checks if the record has a phone number, and if so, adds a UserIdentifier # for it. unless raw_record["phone"].nil? cc.user_identifiers << client.resource.user_identifier do |ui| ui.hashed_phone_number = normalize_and_hash(raw_record["phone"]) end end end
Perl
# Create an empty click conversion. my $click_conversion = Google::Ads::GoogleAds::V26::Services::ConversionUploadService::ClickConversion ->new({}); # Extract user email and phone from the raw data, normalize and hash it, # then wrap it in UserIdentifier objects. Create a separate UserIdentifier # object for each. # The data in this example is hardcoded, but in your application # you might read the raw data from an input file. # # IMPORTANT: Since the identifier attribute of UserIdentifier # (https://developers.google.com/google-ads/api/reference/rpc/latest/UserIdentifier) # is a oneof # (https://protobuf.dev/programming-guides/proto3/#oneof-features), you must set # only ONE of hashed_email, hashed_phone_number, mobile_id, third_party_user_id, # or address-info. Setting more than one of these attributes on the same UserIdentifier # will clear all the other members of the oneof. For example, the following code is # INCORRECT and will result in a UserIdentifier with ONLY a hashed_phone_number: # # my $incorrect_user_identifier = Google::Ads::GoogleAds::V26::Common::UserIdentifier->new({ # hashedEmail => '...', # hashedPhoneNumber => '...', # }); my $raw_record = { # Email address that includes a period (.) before the Gmail domain. email => 'alex.2@example.com', # Phone number to be converted to E.164 format, with a leading '+' as # required. phone => '+1 800 5550102', # This example lets you input conversion details as arguments, # but in reality you might store this data alongside other user data, # so we include it in this sample user record. orderId => $order_id, gclid => $gclid, conversionActionId => $conversion_action_id, conversionDateTime => $conversion_date_time, conversionValue => $conversion_value, currencyCode => "USD", adUserDataConsent => $ad_user_data_consent }; my $user_identifiers = []; # Create a user identifier using the hashed email address, using the normalize # and hash method specifically for email addresses. my $hashed_email = normalize_and_hash_email_address($raw_record->{email}); push( @$user_identifiers, Google::Ads::GoogleAds::V26::Common::UserIdentifier->new({ hashedEmail => $hashed_email, # Optional: Specify the user identifier source. userIdentifierSource => FIRST_PARTY })); # Create a user identifier using normalized and hashed phone info. my $hashed_phone = normalize_and_hash($raw_record->{phone}); push( @$user_identifiers, Google::Ads::GoogleAds::V26::Common::UserIdentifier->new({ hashedPhone => $hashed_phone, # Optional: Specify the user identifier source. userIdentifierSource => FIRST_PARTY })); # Add the user identifiers to the conversion. $click_conversion->{userIdentifiers} = $user_identifiers;
curl
ตัวอย่างนี้แสดงวิธีตั้งค่าฟิลด์อื่นๆ ที่จำเป็นในออบเจ็กต์ ClickConversion
Java
// Adds details of the conversion. clickConversionBuilder.setConversionAction( ResourceNames.conversionAction( customerId, Long.parseLong(rawRecord.get("conversionActionId")))); clickConversionBuilder.setConversionDateTime(rawRecord.get("conversionDateTime")); clickConversionBuilder.setConversionValue(Double.parseDouble(rawRecord.get("conversionValue"))); clickConversionBuilder.setCurrencyCode(rawRecord.get("currencyCode")); // Sets the order ID if provided. if (rawRecord.containsKey("orderId")) { clickConversionBuilder.setOrderId(rawRecord.get("orderId")); } // Sets the Google click ID (gclid) if provided. if (rawRecord.containsKey("gclid")) { clickConversionBuilder.setGclid(rawRecord.get("gclid")); } // Sets the consent information, if provided. if (rawRecord.containsKey("adUserDataConsent")) { // Specifies whether user consent was obtained for the data you are uploading. See // https://www.google.com/about/company/user-consent-policy for details. clickConversionBuilder.setConsent( Consent.newBuilder() .setAdUserData(ConsentStatus.valueOf(rawRecord.get("adUserDataConsent")))); } // Sets one of the sessionAttributesEncoded or sessionAttributesKeyValuePairs if either is // provided. The session attribute fields are only available to allowlisted users. // To include these fields in conversion imports, upgrade to the Data Manager API. if (rawRecord.containsKey("sessionAttributesEncoded")) { clickConversionBuilder.setSessionAttributesEncoded( ByteString.copyFromUtf8(rawRecord.get("sessionAttributesEncoded"))); } else if (rawRecord.containsKey("sessionAttributesMap")) { List<String> pairings = Arrays.stream(rawRecord.get("sessionAttributesMap").split(" ")) .map(String::trim) .collect(Collectors.toList()); SessionAttributesKeyValuePairs.Builder sessionAttributePairs = SessionAttributesKeyValuePairs.newBuilder(); for (String pair : pairings) { String[] parts = pair.split("=", 2); if (parts.length != 2) { throw new IllegalArgumentException( "Failed to read the sessionAttributesMap. SessionAttributesMap must use a" + " space-delimited list of session attribute key value pairs. Each pair should" + " be separated by an equal sign, for example: 'gad_campaignid=12345" + " gad_source=1'"); } sessionAttributePairs.addKeyValuePairs( SessionAttributeKeyValuePair.newBuilder() .setSessionAttributeKey(parts[0]) .setSessionAttributeValue(parts[1]) .build()); } clickConversionBuilder.setSessionAttributesKeyValuePairs(sessionAttributePairs.build()); } // Calls build to build the conversion. ClickConversion clickConversion = clickConversionBuilder.build();
C#
// Adds details of the conversion. clickConversion.ConversionAction = ResourceNames.ConversionAction(customerId, conversionActionId); clickConversion.ConversionDateTime = conversionDateTime; clickConversion.ConversionValue = conversionValue; clickConversion.CurrencyCode = "USD"; // Sets the order ID if provided. if (!string.IsNullOrEmpty(orderId)) { clickConversion.OrderId = orderId; } // Sets the Google click ID (gclid) if provided. if (!string.IsNullOrEmpty(gclid)) { clickConversion.Gclid = gclid; } // The session attribute fields are only available to allowlisted users. To // include these fields in conversion imports, upgrade to the Data Manager API. if (!string.IsNullOrEmpty(sessionAttributesEncoded)) { clickConversion.SessionAttributesEncoded = ByteString.CopyFrom(sessionAttributesEncoded, Encoding.Unicode); } else if (!string.IsNullOrEmpty(sessionAttributes)) { IEnumerable<SessionAttributeKeyValuePair> parsedSessionAttributes = sessionAttributes.Split(';').Select(pair => { string[] split = pair.Split('='); return new SessionAttributeKeyValuePair() { SessionAttributeKey = split[0], SessionAttributeValue = split[1] }; }); clickConversion.SessionAttributesKeyValuePairs = new SessionAttributesKeyValuePairs(); clickConversion.SessionAttributesKeyValuePairs.KeyValuePairs .AddRange(parsedSessionAttributes); }
PHP
// Adds details of the conversion. $clickConversion->setConversionAction( ResourceNames::forConversionAction($customerId, $rawRecord['conversionActionId']) ); $clickConversion->setConversionDateTime($rawRecord['conversionDateTime']); $clickConversion->setConversionValue($rawRecord['conversionValue']); $clickConversion->setCurrencyCode($rawRecord['currencyCode']); // Sets the order ID if provided. if (!empty($rawRecord['orderId'])) { $clickConversion->setOrderId($rawRecord['orderId']); } // Sets the Google click ID (gclid) if provided. if (!empty($rawRecord['gclid'])) { $clickConversion->setGclid($rawRecord['gclid']); } // Sets the ad user data consent if provided. if (!empty($rawRecord['adUserDataConsent'])) { // Specifies whether user consent was obtained for the data you are uploading. See // https://www.google.com/about/company/user-consent-policy for details. $clickConversion->setConsent( new Consent(['ad_user_data' => $rawRecord['adUserDataConsent']]) ); } // Set one of the sessionAttributesEncoded or // SessionAttributeKeyValuePair fields if either are provided. The session attribute // fields are only available to allowlisted users. To include these fields in conversion // imports, upgrade to the Data Manager API. if (!empty($sessionAttributesEncoded)) { $clickConversion->setSessionAttributesEncoded($sessionAttributesEncoded); } elseif (!empty($sessionAttributesDict)) { // Create a new container object to hold key-value pairs. $sessionAttributesKeyValuePairs = new SessionAttributesKeyValuePairs(); // Initialize an array to hold individual key-value pair messages. $keyValuePairs = []; // Append each key-value pair provided to the $keyValuePairs array foreach ($sessionAttributesDict as $key => $value) { $pair = new SessionAttributeKeyValuePair(); $pair->setSessionAttributeKey($key); $pair->setSessionAttributeValue($value); $keyValuePairs[] = $pair; } // Set the the full list of key-value pairs on the container object. $sessionAttributesKeyValuePairs->setKeyValuePairs($keyValuePairs); // Attach the container of key-value pairs to the ClickConversion object. $clickConversion->setSessionAttributesKeyValuePairs($sessionAttributesKeyValuePairs); }
Python
# Add details of the conversion. # Gets the conversion action resource name. conversion_action_service: ConversionActionServiceClient = ( client.get_service("ConversionActionService") ) click_conversion.conversion_action = ( conversion_action_service.conversion_action_path( customer_id, raw_record["conversion_action_id"] ) ) click_conversion.conversion_date_time = raw_record["conversion_date_time"] click_conversion.conversion_value = raw_record["conversion_value"] click_conversion.currency_code = raw_record["currency_code"] # Sets the order ID if provided. if raw_record.get("order_id"): click_conversion.order_id = raw_record["order_id"] # Sets the gclid if provided. if raw_record.get("gclid"): click_conversion.gclid = raw_record["gclid"] # Specifies whether user consent was obtained for the data you are # uploading. For more details, see: # https://www.google.com/about/company/user-consent-policy if raw_record["ad_user_data_consent"]: click_conversion.consent.ad_user_data = client.enums.ConsentStatusEnum[ raw_record["ad_user_data_consent"] ] # Set one of the session_attributes_encoded or # session_attributes_key_value_pairs fields if either are provided. # The session attribute fields are only available to allowlisted users. # To include these fields in conversion imports, upgrade to the Data Manager API. if session_attributes_encoded: click_conversion.session_attributes_encoded = session_attributes_encoded elif session_attributes_dict: for key, value in session_attributes_dict.items(): pair: SessionAttributeKeyValuePair = client.get_type( "SessionAttributeKeyValuePair" ) pair.session_attribute_key = key pair.session_attribute_value = value click_conversion.session_attributes_key_value_pairs.key_value_pairs.append( pair )
Ruby
cc.conversion_action = client.path.conversion_action(customer_id, conversion_action_id) cc.conversion_date_time = conversion_date_time cc.conversion_value = conversion_value.to_f cc.currency_code = 'USD' unless order_id.nil? cc.order_id = order_id end unless raw_record["gclid"].nil? cc.gclid = gclid end # Specifies whether user consent was obtained for the data you are # uploading. For more details, see: # https://www.google.com/about/company/user-consent-policy unless raw_record["ad_user_data_consent"].nil? cc.consent = client.resource.consent do |c| c.ad_user_data = ad_user_data_consent end end # Set one of the session_attributes_encoded or # session_attributes_key_value_pairs fields if either are provided. # The session attribute fields are only available to allowlisted users. # To include these fields in conversion imports, upgrade to the Data Manager API. if session_attributes_encoded != nil cc.class.module_eval { attr_accessor :session_attributes_encoded} cc.session_attributes_encoded = session_attributes_encoded elsif session_attributes_hash != nil # Add new attribute to click conversion object cc.class.module_eval { attr_accessor :session_attributes_key_value_pairs} cc.session_attributes_key_value_pairs = ::Google::Ads::GoogleAds::V19::Services::SessionAttributesKeyValuePairs.new # Loop thru inputted session_attributes_hash to populate session_attributes_key_value_pairs session_attributes_hash.each do |key, value| pair = ::Google::Ads::GoogleAds::V19::Services::SessionAttributeKeyValuePair.new pair.session_attribute_key = key pair.session_attribute_value = value cc.session_attributes_key_value_pairs.key_value_pairs << pair end end
Perl
# Add details of the conversion. $click_conversion->{conversionAction} = Google::Ads::GoogleAds::V26::Utils::ResourceNames::conversion_action( $customer_id, $raw_record->{conversionActionId}); $click_conversion->{conversionDateTime} = $raw_record->{conversionDateTime}; $click_conversion->{conversionValue} = $raw_record->{conversionValue}; $click_conversion->{currencyCode} = $raw_record->{currencyCode}; # Set the order ID if provided. if (defined $raw_record->{orderId}) { $click_conversion->{orderId} = $raw_record->{orderId}; } # Set the Google click ID (gclid) if provided. if (defined $raw_record->{gclid}) { $click_conversion->{gclid} = $raw_record->{gclid}; } # Set the consent information, if provided. if (defined $raw_record->{adUserDataConsent}) { $click_conversion->{consent} = Google::Ads::GoogleAds::V26::Common::Consent->new({ adUserData => $raw_record->{adUserDataConsent}}); } # Set one of the session_attributes_encoded or session_attributes_key_value_pairs # fields if either are provided. if (defined $session_attributes_encoded) { $click_conversion->{sessionAttributesEncoded} = $session_attributes_encoded; } elsif (defined $session_attributes_hash) { while (my ($key, $value) = each %$session_attributes_hash) { my $pair = Google::Ads::GoogleAds::V26::Services::ConversionUploadService::SessionAttributeKeyValuePair ->new({sessionAttributeKey => $key, sessionAttributeValue => $value}); push @{$click_conversion->{sessionAttributesKeyValuePairs}{keyValuePairs} }, $pair; } }
curl
สร้างคำขอ
เมื่อกำหนดค่าและเพิ่มออบเจ็กต์ ClickConversion ลงในฟิลด์ conversions ของออบเจ็กต์ UploadClickConversionsRequest แล้ว ให้ตั้งค่าฟิลด์ต่อไปนี้และส่งคำขอไปยังเมธอด UploadClickConversions ใน ConversionUploadService
customer_id- ตั้งค่านี้เป็นลูกค้า Conversion โฆษณาของ Google Ads ของบัญชีที่เป็นแหล่งที่มาของการคลิก หากไม่แน่ใจว่าบัญชีใดเป็นบัญชีที่ถูกต้อง โปรดดูช่อง
customer.conversion_tracking_setting.google_ads_conversion_customerในตัวอย่างการค้นหาในส่วนเริ่มต้นใช้งาน job_idมีกลไกในการเชื่อมโยงคำขอนำเข้ากับข้อมูลต่องานในการวินิจฉัยข้อมูลออฟไลน์
หากคุณไม่ได้ตั้งค่าช่องนี้ Google Ads API จะกำหนดค่าที่ไม่ซ้ำกันให้กับแต่ละคำขอ ในช่วง
[2^31, 2^63)หากต้องการจัดกลุ่มคำขอหลายรายการเป็นงานเชิงตรรกะเดียว ให้ตั้งค่าช่องนี้เป็นค่าเดียวกันในช่วง[0, 2^31)สำหรับคำขอทุกรายการในงานjob_idในการตอบกลับจะมีรหัสงานสำหรับคำขอ ไม่ว่าคุณจะระบุค่าหรือให้ Google Ads API กำหนดค่าให้ก็ตามpartial_failureต้องตั้งค่าช่องนี้เป็น
trueเมื่อนำเข้า Conversion ปฏิบัติตามหลักเกณฑ์เกี่ยวกับความล้มเหลวบางส่วนเมื่อประมวลผลการตอบกลับ
นำเข้าคำขอ
เมื่อป้อนข้อมูลออบเจ็กต์ ClickConversion และสร้างคำขอแล้ว คุณจะส่งการนำเข้าได้
Java
// Creates the conversion upload service client. try (ConversionUploadServiceClient conversionUploadServiceClient = googleAdsClient.getLatestVersion().createConversionUploadServiceClient()) { // Uploads the click conversion. Partial failure should always be set to true. // NOTE: This request contains a single conversion as a demonstration. However, if you have // multiple conversions to upload, it's best to upload multiple conversions per request // instead of sending a separate request per conversion. See the following for per-request // limits: // https://developers.google.com/google-ads/api/docs/best-practices/quotas#conversion_upload_service UploadClickConversionsResponse response = conversionUploadServiceClient.uploadClickConversions( UploadClickConversionsRequest.newBuilder() .setCustomerId(Long.toString(customerId)) .addConversions(clickConversion) // Enables partial failure (must be true). .setPartialFailure(true) .build());
C#
// Uploads the click conversion. Partial failure should always be set to true. // NOTE: This request contains a single conversion as a demonstration. // However, if you have multiple conversions to upload, it's best to upload multiple // conversions per request instead of sending a separate request per conversion. // See the following for per-request limits: // https://developers.google.com/google-ads/api/docs/best-practices/quotas#conversion_upload UploadClickConversionsResponse response = conversionUploadService.UploadClickConversions( new UploadClickConversionsRequest() { CustomerId = customerId.ToString(), Conversions = { clickConversion }, // Enables partial failure (must be true). PartialFailure = true });
PHP
// Issues a request to upload the click conversion. $conversionUploadServiceClient = $googleAdsClient->getConversionUploadServiceClient(); // NOTE: This request contains a single conversion as a demonstration. However, if you have // multiple conversions to upload, it's best to upload multiple conversions per request // instead of sending a separate request per conversion. See the following for per-request // limits: // https://developers.google.com/google-ads/api/docs/best-practices/quotas#conversion_upload_service $response = $conversionUploadServiceClient->uploadClickConversions( // Enables partial failure (must be true). UploadClickConversionsRequest::build($customerId, [$clickConversion], true) );
Python
# Creates the conversion upload service client. conversion_upload_service: ConversionUploadServiceClient = ( client.get_service("ConversionUploadService") ) # Uploads the click conversion. Partial failure should always be set to # True. # NOTE: This request only uploads a single conversion, but if you have # multiple conversions to upload, it's most efficient to upload them in a # single request. See the following for per-request limits for reference: # https://developers.google.com/google-ads/api/docs/best-practices/quotas#conversion_upload_service response: UploadClickConversionsResponse = ( conversion_upload_service.upload_click_conversions( customer_id=customer_id, conversions=[click_conversion], # Enables partial failure (must be true). partial_failure=True, ) )
Ruby
response = client.service.conversion_upload.upload_click_conversions( customer_id: customer_id, conversions: [click_conversion], # Partial failure must be true. partial_failure: true, ) if response.partial_failure_error puts "Partial failure encountered: #{response.partial_failure_error.message}" else result = response.results.first puts "Uploaded click conversion that happened at #{result.conversion_date_time} " \ "to #{result.conversion_action}." end
Perl
# Upload the click conversion. Partial failure should always be set to true. # # NOTE: This request contains a single conversion as a demonstration. # However, if you have multiple conversions to upload, it's best to # upload multiple conversions per request instead of sending a separate # request per conversion. See the following for per-request limits: # https://developers.google.com/google-ads/api/docs/best-practices/quotas#conversion_upload_service my $response = $api_client->ConversionUploadService()->upload_click_conversions({ customerId => $customer_id, conversions => [$click_conversion], # Enable partial failure (must be true). partialFailure => "true" });
curl
โครงสร้างคำขอและการตอบกลับของ REST
เมื่อเรียกใช้
ConversionUploadService.UploadClickConversions ผ่าน REST
ให้ส่งคำขอ POST โดยตั้งค่า partialFailure เป็น true
POST https://googleads.googleapis.com/v26/customers/{customer_id}:uploadClickConversions
{
"partialFailure": true,
"jobId": 1001,
"conversions": [
{
"conversionAction": "customers/{customer_id}/conversionActions/{conversion_action_id}",
"conversionDateTime": "2026-06-01 14:30:00-04:00",
"conversionValue": 125.50,
"currencyCode": "USD",
"orderId": "ORDER-2026-0001",
"gclid": "EAIaIQobChMI...",
"consent": {
"adUserData": "GRANTED"
},
"userIdentifiers": [
{
"userIdentifierSource": "FIRST_PARTY",
"hashedEmail": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a"
},
{
"userIdentifierSource": "FIRST_PARTY",
"hashedPhoneNumber": "42975f8f9e46c2e13c1a2294957e5cb8d8e6f4f7341a036c6e595bc9f5e24621"
}
]
},
{
"conversionAction": "customers/{customer_id}/conversionActions/{conversion_action_id}",
"conversionDateTime": "2026-06-01 14:35:00-04:00",
"conversionValue": 80.00,
"currencyCode": "USD",
"orderId": "ORDER-2026-0002",
"gclid": "EAIaIQobChMI_expired...",
"consent": {
"adUserData": "GRANTED"
}
}
]
}
ในกลุ่ม Conversion 2 รายการนี้ซึ่งรายการที่ 2 ไม่สำเร็จ แถวที่สำเร็จจะแสดงรายการ ClickConversionResult ที่มีข้อมูลใน results[] ขณะที่แถวที่ไม่สำเร็จจะแสดงออบเจ็กต์ {} ที่ว่างเปล่าใน results[] พร้อมกับรายละเอียดข้อผิดพลาดใน partialFailureError ใน UploadClickConversionsResponse
{
"results": [
{
"conversionAction": "customers/{customer_id}/conversionActions/{conversion_action_id}",
"conversionDateTime": "2026-06-01 14:30:00-04:00",
"gclid": "EAIaIQobChMI...",
"userIdentifiers": [
{
"userIdentifierSource": "FIRST_PARTY",
"hashedEmail": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a"
},
{
"userIdentifierSource": "FIRST_PARTY",
"hashedPhoneNumber": "42975f8f9e46c2e13c1a2294957e5cb8d8e6f4f7341a036c6e595bc9f5e24621"
}
]
},
{}
],
"jobId": "1001",
"partialFailureError": {
"code": 3,
"message": "The click associated with the given identifier or iOS URL parameter occurred less recently than the maximum lookback window., at conversions[1].gclid",
"details": [
{
"@type": "type.googleapis.com/google.ads.googleads.v26.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
"conversionUploadError": "EXPIRED_EVENT"
},
"message": "The click associated with the given identifier or iOS URL parameter occurred less recently than the maximum lookback window.",
"location": {
"fieldPathElements": [
{
"fieldName": "conversions",
"index": 1
},
{
"fieldName": "gclid"
}
]
}
}
]
}
]
}
}
ตรวจสอบการนำเข้า
ใช้รายงานการวินิจฉัย Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายเพื่อตรวจสอบประสิทธิภาพโดยรวมของการนําเข้าล่าสุด
วินิจฉัยการอัปโหลดคำค้นหาด้วย GAQL
นอกจากนี้ คุณยังตรวจสอบสถานะการอัปโหลดระดับบัญชี จำนวนงานล่าสุด และการแจ้งเตือนข้อผิดพลาด
แบบเป็นโปรแกรมได้โดยการค้นหา
offline_conversion_upload_client_summary เทียบกับ
รหัสลูกค้า Conversion
SELECT
customer.id,
offline_conversion_upload_client_summary.client,
offline_conversion_upload_client_summary.status,
offline_conversion_upload_client_summary.total_event_count,
offline_conversion_upload_client_summary.successful_event_count,
offline_conversion_upload_client_summary.success_rate,
offline_conversion_upload_client_summary.pending_event_count,
offline_conversion_upload_client_summary.pending_rate,
offline_conversion_upload_client_summary.last_upload_date_time,
offline_conversion_upload_client_summary.alerts,
offline_conversion_upload_client_summary.daily_summaries,
offline_conversion_upload_client_summary.job_summaries
FROM offline_conversion_upload_client_summary
Conversion ที่นำเข้าจะแสดงในรายงานสำหรับวันที่การแสดงผลของการคลิกเดิม ไม่ใช่วันที่ของคำขอ
นำเข้าหรือวันที่ของconversion_date_timeของClickConversion
ระบบใช้เวลาสูงสุด 3 ชั่วโมงในการแสดงสถิติ Conversion ที่นำเข้าในบัญชี Google Ads สำหรับการระบุแหล่งที่มาของคลิกสุดท้าย สำหรับรูปแบบการระบุแหล่งที่มาของการค้นหาอื่นๆ อาจใช้เวลานานกว่า 3 ชั่วโมง ดูข้อมูลเพิ่มเติมได้ที่คู่มือความใหม่ของข้อมูล
เมื่อรายงานเมตริก Conversion ของแคมเปญ โปรดดูการแมปเมตริกอินเทอร์เฟซผู้ใช้เพื่อเชื่อมโยงเมตริก UI ของ Google Ads กับช่องการรายงานของ Google Ads API นอกจากนี้ คุณยังสามารถค้นหาแหล่งข้อมูล conversion_action เพื่อดูจํานวน Conversion ทั้งหมดและมูลค่า Conversion ทั้งหมดสําหรับการกระทําที่ถือเป็น Conversion ที่กําหนดได้ด้วย
แนวทางปฏิบัติแนะนำ
โปรดคำนึงถึงแนวทางปฏิบัติแนะนำต่อไปนี้เมื่อใช้ Conversion ที่ปรับปรุงแล้ว สำหรับโอกาสในการขาย
ส่งข้อมูล Conversion ทั้งหมดโดยไม่คำนึงถึงความสมบูรณ์
นำเข้าเหตุการณ์ Conversion ออฟไลน์ทั้งหมดที่มี รวมถึงเหตุการณ์ที่อาจไม่ได้มาจาก Google Ads เพื่อให้การรายงาน Conversion สมบูรณ์และถูกต้อง Conversion ที่มีเฉพาะข้อมูลที่ได้จากผู้ใช้ยังคงมีประโยชน์และช่วยเพิ่มประสิทธิภาพแคมเปญ Google Ads ได้
หากคุณกำหนด order_id ให้กับ Conversion เราขอแนะนำให้ระบุข้อมูลนี้ด้วย หากคุณมี GCLID สำหรับ Conversion เราขอแนะนำให้ส่ง GCLID นอกเหนือจาก user_identifiers เพื่อประสิทธิภาพที่ดีขึ้น นอกจากนี้ หากคุณมี UserIdentifier มากกว่า 1 รายการสําหรับ Conversion ให้ใส่ทั้งหมดในออบเจ็กต์ ClickConversion เพื่อเพิ่มโอกาสในการจับคู่
จัดกลุ่ม Conversion หลายรายการไว้ในคำขอเดียว
หากมี Conversion หลายรายการที่จะนำเข้า ให้รวม Conversion เป็น UploadClickConversionsRequest เดียว แทนที่จะส่งคำขอนำเข้าต่อ Conversion
ดูคู่มือโควต้าเพื่อดูขีดจำกัดจำนวน Conversion ต่อคำขอ
หากต้องการให้การวินิจฉัยข้อมูลออฟไลน์จัดกลุ่มชุดคำขอภายใต้งานเชิงตรรกะเดียวกัน ให้ตั้งค่า job_id ของคำขอทั้งหมดเป็นค่าเดียวกัน ซึ่งจะเป็นประโยชน์หากคุณมีงานหรือกระบวนการเดียวที่นําเข้า Conversion จํานวนมากโดยใช้คําขอหลายรายการ หากคุณตั้งค่า job_id ในคำขอแต่ละรายการเป็นค่าเดียวกัน คุณจะดึงข้อมูลรายการเดียวสำหรับงานจาก job_summaries ได้
แต่หากคุณให้ Google Ads API กําหนดค่าที่ระบบสร้างขึ้นให้กับ job_id
ของคําขอแต่ละรายการ job_summaries จะมีรายการแยกต่างหากสําหรับคําขอแต่ละรายการ
ซึ่งอาจทําให้การวิเคราะห์สถานะโดยรวมของงานมีความท้าทายมากขึ้น
อย่าใช้ข้อมูลการระบุแหล่งที่มาภายนอก
เมื่อใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย อย่าตั้งค่า external_attribution_data ใน ClickConversion หรือระบุ conversion_action ที่ใช้รูปแบบการระบุแหล่งที่มาภายนอก Google Ads ไม่รองรับ Conversion ที่มีการระบุแหล่งที่มาจากภายนอกสําหรับการนําเข้าโดยใช้ข้อมูลที่ได้จากผู้ใช้
อย่าใส่ตัวแปรที่กำหนดเอง
เมื่อใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขาย โปรดอย่าใส่ custom_variables Google Ads ไม่รองรับการใช้ตัวแปรที่กำหนดเองกับข้อมูลที่ได้จากผู้ใช้ในการนําเข้า Conversion หากมีการรวมตัวแปรที่กําหนดเองไว้กับ Conversion ที่มีข้อมูลที่ได้จากผู้ใช้ ระบบจะถือว่า Conversion เหล่านั้นไม่ถูกต้องและจะถูกลบออก
การแก้ปัญหา
การวินิจฉัยข้อมูลออฟไลน์เป็นแหล่งข้อมูลเดียวสำหรับการตรวจสอบประสิทธิภาพโดยรวมของการนำเข้าอย่างต่อเนื่อง อย่างไรก็ตาม ในระหว่างการติดตั้งใช้งาน คุณสามารถใช้ข้อมูลในส่วนนี้เพื่อตรวจสอบข้อผิดพลาดที่รายงานในฟิลด์ partial_failure_error ของการตอบกลับได้
ข้อผิดพลาดที่พบบ่อยที่สุดเมื่อนําเข้าการกระทําที่ถือเป็น Conversion คือข้อผิดพลาดในการให้สิทธิ์ เช่น USER_PERMISSION_DENIED ตรวจสอบอีกครั้งว่าคุณได้ตั้งค่ารหัสลูกค้าในคำขอเป็นลูกค้า Conversion โฆษณาของ Google Ads ที่เป็นเจ้าของการกระทำที่ถือเป็น Conversion ดูรายละเอียดเพิ่มเติมได้ที่คู่มือการให้สิทธิ์ และดูเคล็ดลับเกี่ยวกับวิธีแก้ไขข้อผิดพลาดต่างๆ ได้ที่คู่มือข้อผิดพลาดที่พบบ่อย
แก้ไขข้อผิดพลาดที่พบบ่อย
คําแนะนําต่อไปนี้จะช่วยคุณวินิจฉัยและแก้ไขข้อผิดพลาดที่พบบ่อยเกี่ยวกับ Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขาย
| ข้อผิดพลาด | |
|---|---|
NO_CONVERSION_ACTION_FOUND
|
การกระทำที่ถือเป็น Conversion ที่ระบุไม่ได้เปิดใช้ หรือบัญชีลูกค้าที่ระบุโดยช่อง ข้อผิดพลาดนี้อาจเกิดขึ้นได้เช่นกันหาก GCLID ในคำขอเป็นของบัญชีลูกค้าที่ไม่มีสิทธิ์เข้าถึงการกระทำที่ถือเป็น Conversion ที่ระบุในคำขอ คุณสามารถยืนยันว่า GCLID เป็นของบัญชีลูกค้าหรือไม่โดยใช้ทรัพยากร |
INVALID_CONVERSION_ACTION_TYPE
|
การกระทำที่ถือเป็น Conversion ที่ระบุมีประเภทที่ไม่ถูกต้องสําหรับ Conversion ที่ปรับปรุงแล้วสําหรับโอกาสในการขาย ตรวจสอบว่า ConversionAction ที่ระบุใน
คำขออัปโหลดมีประเภทเป็น UPLOAD_CLICKS
|
CUSTOMER_NOT_ENABLED_ENHANCED_CONVERSIONS_FOR_LEADS
|
ตรวจสอบว่าคุณได้เปิดใช้ Conversion ที่ปรับปรุงแล้วสำหรับโอกาสในการขายในการตั้งค่า Conversion ดูวิธีการสำหรับขั้นตอนนี้ได้ในคู่มือข้อกำหนดเบื้องต้น |
DUPLICATE_ORDER_ID
|
เหตุการณ์ที่นําเข้ามี Conversion หลายรายการที่มีรหัสคําสั่งซื้อเดียวกัน และไม่ได้รับการประมวลผล ตรวจสอบว่ารหัสคําสั่งซื้อไม่ซ้ำกัน แล้วลองอีกครั้ง |
CLICK_NOT_FOUND
|
ไม่พบการคลิกที่ตรงกับตัวระบุผู้ใช้ที่ระบุ
หาก Conversion พบคำเตือนนี้ Google Ads API
จะรวมไว้ใน ข้อผิดพลาดนี้เป็นสิ่งที่คาดว่าจะเกิดขึ้นหากคลิกไม่ได้มาจากแคมเปญ Google Ads เช่น อาจมาจาก SA360 หรือ DV360 สาเหตุอื่นๆ ที่เป็นไปได้มีดังนี้
ในกรณีที่พบได้น้อยครั้งซึ่งลูกค้าที่อัปโหลดแตกต่างจากลูกค้า Conversion ของ Google Ads ข้อผิดพลาดนี้อาจหมายความว่าลูกค้าที่อัปโหลดได้ยอมรับข้อกำหนดด้านข้อมูลลูกค้าแล้ว แต่ลูกค้าที่แสดงโฆษณายังไม่ได้ยอมรับ คุณสามารถตรวจสอบว่าบัญชีได้ยอมรับข้อกำหนดสำหรับข้อมูลลูกค้าหรือไม่โดยค้นหาทรัพยากรcustomer และตรวจสอบช่อง customer.conversion_tracking_setting.accepted_customer_data_terms
|