ऑफ़लाइन कन्वर्ज़न मैनेज करना

Google Ads API का इस्तेमाल करके, Google Ads में ऑफ़लाइन कन्वर्ज़न इंपोर्ट किए जा सकते हैं. इससे, उन विज्ञापनों को ट्रैक किया जा सकता है जिनकी वजह से ऑफ़लाइन प्लैटफ़ॉर्म पर बिक्री हुई है. जैसे, फ़ोन पर या सेल्स रेप्रज़ेंटेटिव की मदद से.

कन्वर्ज़न डेटा इंपोर्ट करने के फ़ायदों का पूरा फ़ायदा पाने के लिए, हमारा सुझाव है कि आप लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा लागू करें. यह सुविधा, GCLID और उपयोगकर्ता से मिले डेटा का इस्तेमाल करके, कन्वर्ज़न को लंबे समय तक सेव रखने और परफ़ॉर्मेंस को बेहतर बनाने में मदद करती है.

बेहतर कन्वर्ज़न ट्रैकिंग

बेहतर कन्वर्ज़न ट्रैकिंग की मदद से, कन्वर्ज़न को ज़्यादा सटीक तरीके से मेज़र किया जा सकता है. इसके लिए, कन्वर्ज़न में पहले पक्ष के कन्वर्ज़न डेटा को जोड़ा जाता है. जैसे, ईमेल पता, नाम, घर का पता, और फ़ोन नंबर.

बेहतर कन्वर्ज़न ट्रैकिंग दो तरह की होती है. ज़्यादा जानकारी के लिए, बेहतर कन्वर्ज़न ट्रैकिंग के बारे में जानकारी वाला सहायता केंद्र लेख पढ़ें.

इस सेक्शन में, ऑफ़लाइन कन्वर्ज़न को बेहतर बनाने का तरीका बताया गया है. इसे लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग भी कहा जाता है.

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग क्या है?

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग, ऑफ़लाइन कन्वर्ज़न इंपोर्ट का अपग्रेड किया गया वर्शन है. यह इंपोर्ट किए गए ऑफ़लाइन कन्वर्ज़न डेटा को बेहतर बनाने के लिए, ईमेल पते जैसे उपयोगकर्ता से मिले डेटा का इस्तेमाल करता है. इससे, डेटा की सटीक जानकारी मिलती है और बिडिंग की परफ़ॉर्मेंस बेहतर होती है. ऑफ़लाइन कन्वर्ज़न इंपोर्ट करने पर, ग्राहक के दिए गए हैश किए गए डेटा का इस्तेमाल, Google Ads कैंपेन को फिर से एट्रिब्यूट करने के लिए किया जाता है. इसके लिए, आपकी वेबसाइट पर इकट्ठा किए गए डेटा (उदाहरण के लिए, लीड फ़ॉर्म) और साइन इन किए हुए उन ग्राहकों से मैच किया जाता है जो आपके विज्ञापन से जुड़े थे. लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा के काम करने के तरीके के बारे में ज़्यादा जानने के लिए, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा के बारे में जानकारी लेख पढ़ें.

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा लागू करने के दो तरीके हैं. यह इस बात पर निर्भर करता है कि आपने अपने वेबपेज पर फ़ॉर्म सबमिशन इवेंट ट्रैक करने के लिए, Google टैग का इस्तेमाल किया है या नहीं. बेहतर परफ़ॉर्मेंस और बेहतर कन्वर्ज़न ट्रैकिंग के लिए, हमारा सुझाव है कि आप लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग के लिए Google टैग का इस्तेमाल करें.

  • अगर आपको शुरू से जानकारी चाहिए, तो ज़रूरी शर्तें सेक्शन से शुरुआत करें.
  • अगर आपने पहले से ही ऑफ़लाइन कन्वर्ज़न इंपोर्ट सेट अप कर लिया है और आपको लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग पर अपग्रेड करना है, तो हमारा सुझाव है कि आप टैगिंग कॉन्फ़िगर करें सेक्शन से शुरू करें.
  • अगर आपने Google टैग पहले से सेट अप कर लिया है या आपको Google टैग का इस्तेमाल नहीं करना है और आपको Google Ads API इंटिग्रेशन पर काम शुरू करना है, तो एपीआई लागू करना सेक्शन पर जाएं.
  • अगर उपयोगकर्ता से मिले डेटा को इंपोर्ट करने में समस्या आ रही है या अपने कन्वर्ज़न के लिए बाहरी एट्रिब्यूशन पर निर्भर रहना पड़ रहा है, तो लेगसी ऑफ़लाइन कन्वर्ज़न इंपोर्ट गाइड देखें.

ज़रूरी शर्तें

सबसे पहले, पक्का करें कि आपने हमारे शुरू करने के सेक्शन में दिए गए निर्देशों का पालन किया हो.

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग का इस्तेमाल करने से पहले, आपको लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग में ऑप्ट इन करना होगा. साथ ही, ग्राहक से जुड़े डेटा की शर्तें स्वीकार करनी होंगी. Google Ads कन्वर्ज़न ग्राहक से यह क्वेरी पूछकर पुष्टि की जा सकती है कि ये ज़रूरी शर्तें पहले से पूरी की जा चुकी हैं या नहीं:

SELECT
  customer.id,
  customer.conversion_tracking_setting.accepted_customer_data_terms,
  customer.conversion_tracking_setting.enhanced_conversions_for_leads_enabled
FROM customer

अगर accepted_customer_data_terms या enhanced_conversions_for_leads_enabled में से कोई एक false है, तो इन ज़रूरी शर्तों को पूरा करने के लिए, सहायता केंद्र में दिए गए निर्देशों का पालन करें.

टैगिंग कॉन्फ़िगर करना

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा चालू करने के लिए, Google टैग को कॉन्फ़िगर करें. इसके लिए, सहायता केंद्र में दिए गए निर्देशों का पालन करें. Google Tag Manager की मदद से, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग सेट अप करने के लिए, इन निर्देशों का पालन करें.

एपीआई लागू करना

Google Ads API का इस्तेमाल करके, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा को इंपोर्ट करने का पूरा तरीका यहां बताया गया है.

  1. उपयोगकर्ता से मिले डेटा को सामान्य और हैश करें. जैसे, ईमेल पता, फ़ोन नंबर, और मेलिंग पता.

  2. उपयोगकर्ता से मिले सामान्य और हैश किए गए डेटा की मदद से, ClickConversion ऑब्जेक्ट भरें.

  3. ConversionUploadService का इस्तेमाल करके, Google Ads API में ClickConversion ऑब्जेक्ट इंपोर्ट करें.

  4. अपने इंपोर्ट की समीक्षा करें.

उपयोगकर्ता से मिले डेटा को सामान्य और हैश करना

गोपनीयता से जुड़ी चिंताओं को दूर करने के लिए, यहां दिए गए डेटा को इंपोर्ट करने से पहले, SHA-256 का इस्तेमाल करके हैश करना ज़रूरी है:

  • ईमेल पता
  • फ़ोन नंबर
  • नाम
  • उपनाम
  • मोहल्ले का पता

हैश के नतीजों का स्टैंडर्ड तय करने के लिए, इन वैल्यू को हैश करने से पहले, आपको ये काम करने होंगे:

  • आगे और पीछे की खाली सफ़ेद जगहों को हटाएं.
  • टेक्स्ट को अंग्रेज़ी के छोटे अक्षरों में बदलें.
  • फ़ोन नंबरों को E164 स्टैंडर्ड के हिसाब से फ़ॉर्मैट करें.
  • gmail.com और googlemail.com ईमेल पतों के डोमेन नेम से पहले के सभी पीरियड (.) हटाएं.

इस डेटा को हैश न करें:

  • देश
  • राज्य
  • शहर
  • पिन कोड

कोड का उदाहरण

इस उदाहरण में, उपयोगकर्ता से मिले डेटा को सामान्य और हैश करने का तरीका बताया गया है.

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 preceding {@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 {
  String normalizedEmail = emailAddress.toLowerCase();
  String[] emailParts = normalizedEmail.split("@");
  if (emailParts.length > 1 && emailParts[1].matches("^(gmail|googlemail)\\.com\\s*")) {
    // 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("\\.", "");
    normalizedEmail = String.format("%s@%s", emailParts[0], emailParts[1]);
  }
  return normalizeAndHash(digest, normalizedEmail);
}
      

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):
    """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 = email_address.strip().lower()
    email_parts = normalized_email.split("@")

    # Check that there are at least two segments
    if len(email_parts) > 1:
        # Checks whether the domain of the email address is either "gmail.com"
        # or "googlemail.com". If this regex does not match then this statement
        # will evaluate to None.
        if re.match(r"^(gmail|googlemail)\.com$", email_parts[1]):
            # Removes any '.' characters from the portion of the email address
            # before the domain if the domain is gmail.com or googlemail.com.
            email_parts[0] = email_parts[0].replace(".", "")
            normalized_email = "@".join(email_parts)

    return normalize_and_hash(normalized_email)


def normalize_and_hash(s):
    """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);
}
      

ClickConversion ऑब्जेक्ट पॉप्युलेट करना

आपके UploadClickConversionRequest में मौजूद ClickConversion ऑब्जेक्ट का कलेक्शन, उन कन्वर्ज़न के सेट को दिखाता है जिन्हें आपको इंपोर्ट करना है. ClickConversion ऑब्जेक्ट बनाते समय, इन बातों का ध्यान रखें:

gclid

GCLID, क्लिक आइडेंटिफ़ायर होते हैं. ये यूआरएल पैरामीटर से तब कैप्चर किए जाते हैं, जब कोई व्यक्ति आपके विज्ञापन पर क्लिक करके आपकी वेबसाइट पर जाता है.

user_identifiers

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग का इस्तेमाल करते समय, आपको user_identifiers फ़ील्ड में, उपयोगकर्ता से मिले सामान्य और हैश किए गए डेटा को भरना ज़रूरी है. अगर आपके पास एक से ज़्यादा यूज़र आइडेंटिफ़ायर उपलब्ध हैं, तो हर आइडेंटिफ़ायर के लिए अलग UserIdentifier बनाएं. हालांकि, ज़्यादा से ज़्यादा पांच आइडेंटिफ़ायर बनाए जा सकते हैं.

conversion_date_time

कन्वर्ज़न की तारीख और समय.

वैल्यू में टाइमज़ोन की जानकारी होनी चाहिए. साथ ही, फ़ॉर्मैट yyyy-mm-dd HH:mm:ss+|-HH:mm होना चाहिए. उदाहरण के लिए: 2022-01-01 19:32:45-05:00 (डेलाइट सेविंग टाइम को अनदेखा करना) .

टाइमज़ोन की वैल्यू किसी भी मान्य वैल्यू के लिए हो सकती है: इसे खाते के टाइमज़ोन से मैच करने की ज़रूरत नहीं है. हालांकि, अगर आपको इंपोर्ट किए गए कन्वर्ज़न डेटा की तुलना, Google Ads के यूज़र इंटरफ़ेस (यूआई) में मौजूद डेटा से करनी है, तो हमारा सुझाव है कि आप अपने Google Ads खाते के टाइमज़ोन का ही इस्तेमाल करें, ताकि कन्वर्ज़न की संख्या मैच हो सके. ज़्यादा जानकारी और उदाहरणों के लिए, सहायता केंद्र पर जाएं. साथ ही, मान्य टाइमज़ोन आईडी की सूची के लिए, कोड और फ़ॉर्मैट देखें.

conversion_action

ऑफ़लाइन कन्वर्ज़न के लिए ConversionAction के संसाधन का नाम.

कन्वर्ज़न ऐक्शन का type UPLOAD_CLICKS होना चाहिए. साथ ही, यह क्लिक से जुड़े Google Ads खाते के Google Ads कन्वर्ज़न ग्राहक में मौजूद होना चाहिए.

conversion_value

कन्वर्ज़न की वैल्यू.

currency_code

conversion_value का मुद्रा कोड.

consent

हमारा बहुत सुझाव है कि आप ClickConversion ऑब्जेक्ट के consent फ़ील्ड को पॉप्युलेट करें. अगर यह सेट नहीं है, तो हो सकता है कि आपके कन्वर्ज़न को एट्रिब्यूट न किया जा सके.

order_id

इसे कन्वर्ज़न के लिए ट्रांज़ैक्शन आईडी भी कहा जाता है. इस फ़ील्ड को भरना ज़रूरी नहीं है. हालांकि, इसका सुझाव दिया जाता है, क्योंकि इससे अडजस्टमेंट करते समय, इंपोर्ट किए गए कन्वर्ज़न का रेफ़रंस देना आसान हो जाता है. अगर आपने इसे इंपोर्ट के दौरान सेट किया है, तो आपको किसी भी बदलाव के लिए इसका इस्तेमाल करना होगा. डुप्लीकेट कन्वर्ज़न को कम करने के लिए, लेन-देन आईडी का इस्तेमाल करने के तरीके के बारे में ज़्यादा जानने के लिए, सहायता केंद्र का यह लेख पढ़ें.

custom_variables

कस्टम कन्वर्ज़न वैरिएबल की वैल्यू.

Google Ads, wbraid या gbraid के साथ कस्टम कन्वर्ज़न वैरिएबल का इस्तेमाल नहीं करता.

conversion_environment

इससे उस एनवायरमेंट के बारे में पता चलता है जहां यह कन्वर्ज़न रिकॉर्ड किया गया था. उदाहरण के लिए, APP या WEB.

session_attributes_encoded और session_attributes_key_value_pairs

सेशन एट्रिब्यूट, कन्वर्ज़न एट्रिब्यूशन के लिए इस्तेमाल किए गए एग्रीगेट किए गए आइडेंटिफ़ायर दिखाते हैं. ये क्लिक आइडेंटिफ़ायर (जैसे, GCLID और GBRAID) और उपयोगकर्ता से मिले डेटा के साथ काम करते हैं. उपयोगकर्ता से मिले डेटा का इस्तेमाल, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा में किया जाता है. सेशन एट्रिब्यूट को इंपोर्ट करने के दो तरीके हैं: ब्राउज़र में हमारे JavaScript कोड से जनरेट किए गए कोड में एन्क्रिप्ट किया गया टोकन देकर या हर आइडेंटिफ़ायर के लिए अलग-अलग की वैल्यू जोड़कर.

अपने कैंपेन की परफ़ॉर्मेंस को बेहतर बनाने के लिए, हमारा सुझाव है कि आप अपने सभी कन्वर्ज़न के साथ क्लिक आइडेंटिफ़ायर, उपयोगकर्ता से मिला डेटा, और सेशन एट्रिब्यूट इंपोर्ट करें. हालांकि, ऐसा तब ही करें, जब आपके पास ऐसा करने का विकल्प हो.

Java

This example is not yet available in Java; you can take a look at the other languages.
    

C#

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.
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 = 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

This example is not yet available in Ruby; you can take a look at the other languages.
    

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::V19::Services::ConversionUploadService::SessionAttributeKeyValuePair
      ->new({sessionAttributeKey => $key, sessionAttributeValue => $value});
    push @{$click_conversion->{sessionAttributesKeyValuePairs}{keyValuePairs}
    }, $pair;
  }
}
      

कोड का उदाहरण

इस उदाहरण में, उपयोगकर्ता से मिले सामान्य और हैश किए गए डेटा को 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", "[email protected]")
        // Phone number to be converted to E.164 format, with a leading '+' as required.
        .put("phone", "+1 800 5550102")
        // 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(normalizeAndHash(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("[email protected]"),
    // 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' => '[email protected]',
    // 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
];

// 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 = {
    # Email address that includes a period (.) before the Gmail domain.
    "email": "[email protected]",
    # 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 = 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 = 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 = 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" => "[email protected]",
  # 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.
  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::V19::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::V19::Common::UserIdentifier->new({
#   hashedEmail => '...',
#   hashedPhoneNumber => '...',
# });
my $raw_record = {
  # Email address that includes a period (.) before the Gmail domain.
  email => '[email protected]',
  # 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::V19::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::V19::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;
      

इस उदाहरण में, 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.
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;
}

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']])
    );
}
      

Python

# Add details of the conversion.
# Gets the conversion action resource name.
conversion_action_service = 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.
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 = 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.
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::V19::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::V19::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::V19::Services::ConversionUploadService::SessionAttributeKeyValuePair
      ->new({sessionAttributeKey => $key, sessionAttributeValue => $value});
    push @{$click_conversion->{sessionAttributesKeyValuePairs}{keyValuePairs}
    }, $pair;
  }
}
      

अनुरोध बनाना

ClickConversion ऑब्जेक्ट कॉन्फ़िगर होने और UploadClickConversionRequest ऑब्जेक्ट के conversions फ़ील्ड में जोड़ने के बाद, नीचे दिए गए फ़ील्ड सेट करें और अनुरोध को ConversionUploadService पर UploadClickConversions तरीके पर पास करें.

customer_id
इसे उस खाते के Google Ads कन्वर्ज़न ग्राहक पर सेट करें जो क्लिक का सोर्स है. अगर आपको नहीं पता कि कौनसा खाता सही है, तो शुरू करने का तरीका सेक्शन में, उदाहरण के तौर पर दी गई क्वेरी में customer.conversion_tracking_setting.google_ads_conversion_customerफ़ील्ड
देखें.
job_id

ऑफ़लाइन डेटा डाइग्नोस्टिक्स में, हर नौकरी की जानकारी के साथ इंपोर्ट के अनुरोधों को जोड़ने का तरीका उपलब्ध कराता है.

अगर इस फ़ील्ड को सेट नहीं किया जाता है, तो Google Ads API हर अनुरोध के लिए, [2^31, 2^63) की रेंज में एक यूनीक वैल्यू असाइन करता है. अगर आपको एक से ज़्यादा अनुरोधों को एक लॉजिकल जॉब में ग्रुप करना है, तो अपनी जॉब के हर अनुरोध के लिए, इस फ़ील्ड को [0, 2^31) की रेंज में एक ही वैल्यू पर सेट करें.

response में मौजूद job_id में, अनुरोध के लिए जॉब आईडी होता है. भले ही, आपने कोई वैल्यू तय की हो या Google Ads API को वैल्यू असाइन करने की अनुमति दी हो.

partial_failure

कन्वर्ज़न इंपोर्ट करते समय, इस फ़ील्ड को true पर सेट करना होगा. जवाब प्रोसेस करते समय, कुछ हिस्से में काम न करने के दिशा-निर्देशों का पालन करें.

अनुरोध इंपोर्ट करना

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 = 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 = 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"
  });
      

इंपोर्ट की समीक्षा करना

हाल ही में इंपोर्ट किए गए डेटा की समीक्षा करने के लिए, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की डाइग्नोस्टिक्स रिपोर्ट का इस्तेमाल करें.

इंपोर्ट किए गए कन्वर्ज़न, रिपोर्ट में ओरिजनल क्लिक की इंप्रेशन तारीख के लिए दिखते हैं, न कि इंपोर्ट अनुरोध की तारीख या ClickConversion के conversion_date_time की तारीख के लिए.

इंपोर्ट किए गए कन्वर्ज़न के आंकड़ों को आपके Google Ads खाते में दिखने में तीन घंटे लग सकते हैं. ऐसा, लास्ट क्लिक एट्रिब्यूशन के लिए होता है. खोज के लिए इस्तेमाल होने वाले अन्य एट्रिब्यूशन मॉडल के लिए, तीन घंटे से ज़्यादा समय लग सकता है. ज़्यादा जानकारी के लिए, डेटा अपडेट होने की फ़्रीक्वेंसी के बारे में जानकारी देने वाली गाइड देखें.

अपने कैंपेन के लिए कन्वर्ज़न मेट्रिक की रिपोर्टिंग करते समय, Google Ads यूज़र इंटरफ़ेस (यूआई) मेट्रिक को Google Ads API रिपोर्टिंग फ़ील्ड से जोड़ने के लिए, यूज़र इंटरफ़ेस मेट्रिक को मैप करना लेख पढ़ें. किसी कन्वर्ज़न ऐक्शन के लिए, कन्वर्ज़न की कुल संख्या और कन्वर्ज़न वैल्यू देखने के लिए, conversion_action रिसॉर्स से क्वेरी भी की जा सकती है.

सबसे सही तरीके

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग लागू करते समय, इन सबसे सही तरीकों को ध्यान में रखें.

पूरा कन्वर्ज़न डेटा भेजें, भले ही वह पूरा न हो

कन्वर्ज़न की पूरी और सटीक रिपोर्टिंग पाने के लिए, सभी उपलब्ध ऑफ़लाइन कन्वर्ज़न इवेंट इंपोर्ट करें. इनमें वे इवेंट भी शामिल हैं जो शायद Google Ads से नहीं मिले हों. सिर्फ़ उपयोगकर्ता से मिले डेटा वाले कन्वर्ज़न अब भी काम के हैं और इनसे Google Ads कैंपेन को ऑप्टिमाइज़ करने में मदद मिल सकती है.

अगर आपने किसी कन्वर्ज़न को order_id असाइन किया है, तो हमारा सुझाव है कि आप उसे शामिल करें. अगर आपके पास किसी कन्वर्ज़न के लिए GCLID है, तो हमारा सुझाव है कि बेहतर परफ़ॉर्मेंस के लिए, user_identifiers के साथ-साथ उसे भी भेजें. इसके अलावा, अगर आपके पास कन्वर्ज़न के लिए एक से ज़्यादा UserIdentifier हैं, तो मैच होने की संभावना बढ़ाने के लिए, उन सभी को ClickConversion ऑब्जेक्ट में शामिल करें.

एक ही अनुरोध में कई कन्वर्ज़न को एक साथ अपलोड करना

अगर आपको एक से ज़्यादा कन्वर्ज़न इंपोर्ट करने हैं, तो हर कन्वर्ज़न के लिए इंपोर्ट का अनुरोध भेजने के बजाय, कन्वर्ज़न को एक UploadClickConversionsRequest में एक साथ डालें.

हर अनुरोध के लिए कन्वर्ज़न की संख्या की सीमाओं के बारे में जानने के लिए, कोटा गाइड देखें.

अगर आपको ऑफ़लाइन डेटा डाइग्नोस्टिक्स की मदद से, एक ही लॉजिकल जॉब के तहत अनुरोधों के सेट को ग्रुप करना है, तो सभी अनुरोधों के job_id को एक ही वैल्यू पर सेट करें. यह तब काम का हो सकता है, जब आपके पास एक ऐसा जॉब या प्रोसेस हो जो कई अनुरोधों का इस्तेमाल करके, बड़ी संख्या में कन्वर्ज़न इंपोर्ट करती हो. अगर आपने उन सभी अनुरोधों पर job_id को एक ही वैल्यू पर सेट किया है, तो job_summaries से नौकरी के लिए एक ही एंट्री वापस पाई जा सकती है. अगर इसके बजाय, Google Ads API को हर अनुरोध के job_id के लिए, सिस्टम से जनरेट की गई वैल्यू असाइन करने की अनुमति दी जाती है, तो job_summaries में हर अनुरोध के लिए एक अलग एंट्री होती है. इससे, नौकरी की परफ़ॉर्मेंस का विश्लेषण करना ज़्यादा मुश्किल हो सकता है.

बाहरी एट्रिब्यूशन डेटा का इस्तेमाल न करना

लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग का इस्तेमाल करते समय, ClickConversion पर external_attribution_data को सेट न करें या ऐसा conversion_action न दें जो बाहरी एट्रिब्यूशन मॉडल का इस्तेमाल करता हो. Google Ads, उपयोगकर्ता से मिले डेटा का इस्तेमाल करके इंपोर्ट किए जाने वाले कन्वर्ज़न के लिए, बाहरी एट्रिब्यूशन का इस्तेमाल नहीं करता.

समस्या का हल

ऑफ़लाइन डेटा डाइग्नोस्टिक्स की मदद से, अपने इंपोर्ट की परफ़ॉर्मेंस की लगातार समीक्षा की जा सकती है. हालांकि, लागू करने के दौरान, जवाब के partial_failure_error फ़ील्ड में बताई गई किसी भी गड़बड़ी की जांच करने के लिए, इस सेक्शन में दी गई जानकारी का इस्तेमाल किया जा सकता है.

कन्वर्ज़न ऐक्शन इंपोर्ट करते समय, अनुमति से जुड़ी गड़बड़ियां सबसे आम तौर पर होती हैं. जैसे, USER_PERMISSION_DENIED. दोबारा जांच लें कि आपके अनुरोध में, कन्वर्ज़न ऐक्शन का मालिकाना हक रखने वाले Google Ads कन्वर्ज़न ग्राहक के लिए ग्राहक आईडी सेट किया गया है या नहीं. ज़्यादा जानकारी के लिए, अनुमति से जुड़ी गाइड पर जाएं. साथ ही, इन अलग-अलग गड़बड़ियों को डीबग करने के तरीके के बारे में सलाह पाने के लिए, सामान्य गड़बड़ियों से जुड़ी गाइड देखें.

सामान्य गड़बड़ियों को डीबग करना

गड़बड़ी
NO_CONVERSION_ACTION_FOUND

तय किया गया कन्वर्ज़न ऐक्शन चालू नहीं है या अनुरोध में `client_id` फ़ील्ड से बताए गए क्लाइंट खाते से ऐक्सेस नहीं किया जा सकता. पक्का करें कि आपके अपलोड में मौजूद कन्वर्ज़न ऐक्शन चालू हो और उसका मालिकाना हक, अपलोड का अनुरोध भेजने वाले ग्राहक के पास हो.

यह गड़बड़ी तब भी हो सकती है, जब अनुरोध में मौजूद GCLID, ऐसे क्लाइंट खाते से जुड़ा हो जिसके पास, अनुरोध में बताए गए कन्वर्ज़न ऐक्शन का ऐक्सेस न हो. click_view रिसॉर्स का इस्तेमाल करके, यह पुष्टि की जा सकती है कि कोई GCLID, क्लाइंट खाते से जुड़ा है या नहीं. इसके लिए, click_view.gclid और segments.date के हिसाब से फ़िल्टर करने वाली क्वेरी सबमिट करें. यहां तारीख, क्लिक होने की तारीख है.

INVALID_CONVERSION_ACTION_TYPE बताए गए कन्वर्ज़न ऐक्शन का टाइप, 'लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग' के लिए मान्य नहीं है. पक्का करें कि अपलोड करने के अनुरोध में बताए गए ConversionAction का टाइप UPLOAD_CLICKS हो.
CUSTOMER_NOT_ENABLED_ENHANCED_CONVERSIONS_FOR_LEADS पक्का करें कि आपने अपनी कन्वर्ज़न सेटिंग में, लीड के लिए बेहतर कन्वर्ज़न ट्रैकिंग की सुविधा चालू की हो. इसके लिए, ज़रूरी शर्तें गाइड में दिए गए निर्देश देखें.
DUPLICATE_ORDER_ID इंपोर्ट किए गए इवेंट में, एक ही ऑर्डर आईडी वाले कई कन्वर्ज़न शामिल हैं. इसलिए, उन्हें प्रोसेस नहीं किया गया. पक्का करें कि ऑर्डर आईडी यूनीक हों. इसके बाद, फिर से कोशिश करें.
CLICK_NOT_FOUND दिए गए उपयोगकर्ता आइडेंटिफ़ायर से मैच करने वाला कोई क्लिक नहीं मिला. Google Ads API, यह गड़बड़ी सिर्फ़ तब दिखाता है, जब debug_enabled, UploadClickConversionsRequest पर true हो.

अगर किसी कन्वर्ज़न को यह चेतावनी मिलती है, तो Google Ads API इसे ऑफ़लाइन डेटा डाइग्नोस्टिक्स के successful_event_count में शामिल करता है. Google Ads API में, alerts कलेक्शन में CLICK_NOT_FOUND के लिए एक एंट्री शामिल होती है, ताकि आप इस चेतावनी की फ़्रीक्वेंसी को मॉनिटर कर सकें.

अगर क्लिक, Google Ads कैंपेन से नहीं मिला है, तो यह गड़बड़ी दिख सकती है. उदाहरण के लिए, यह SA360 या DV360 से मिल सकता है. इसकी अन्य वजहें ये हो सकती हैं:

कुछ मामलों में, अपलोड करने वाला ग्राहक, Google Ads कन्वर्ज़न ग्राहक से अलग होता है. ऐसे में, इस गड़बड़ी का मतलब यह हो सकता है कि अपलोड करने वाले ग्राहक ने ग्राहक डेटा की शर्तें स्वीकार कर ली हैं, लेकिन विज्ञापन दिखाने वाले ग्राहक ने नहीं.

customer संसाधन से क्वेरी करके और customer.offline_conversion_tracking_info.accepted_customer_data_terms फ़ील्ड की जांच करके, यह पता लगाया जा सकता है कि किसी खाते ने ग्राहक से जुड़े डेटा की शर्तें स्वीकार की हैं या नहीं.