Google के सहमति मैनेजमेंट से जुड़े SDK टूल

एसडीके टूल के लिए, Google की डेवलपर गाइड देखें:

  • AdMob ऐप्लिकेशन (Android, iOS)
  • Ad Manager ऐप्लिकेशन (Android, iOS)

एसडीके की सभी ज़रूरी शर्तों और उसे लागू करने के बारे में जानने के लिए, इस दस्तावेज़ की शुरुआत में दी गई गाइड देखें. अगर आपने Privacy & messaging में सहमति मोड की सुविधा चालू की है, तो आपको यहां बताई गई अतिरिक्त सुविधाओं को भी लागू करना चाहिए.

ज़रूरी एसडीके लागू करने, निजता और मैसेजिंग में Google के सहमति मोड को चालू करने, और यह तय करने के बाद कि आपको सहमति मोड का बेसिक वर्शन लागू करना है, इन निर्देशों का पालन करें.

बेसिक मोड लागू करने के लिए:

  1. Analytics की डेटा कलेक्शन प्रोसेस को कुछ समय के लिए बंद करना (Android, iOS).
  2. Google Analytics की सुविधा को अनब्लॉक करने के लिए, Analytics कलेक्शन (Android, iOS) को फिर से चालू करें.

दूसरे चरण के लिए, किसी कानूनी विशेषज्ञ से सलाह लें. इससे आपको Analytics की सुविधा को फिर से चालू करने की शर्तों के बारे में पता चलेगा.

उदाहरण के लिए, उपयोगकर्ता के सहमति देने के बाद, Google Analytics की सुविधा को फिर से चालू किया जा सकता है. इसके लिए, loadAndShowConsentFormIfRequired (एपीआई रेफ़रंस: Android, iOS) के कॉलबैक में Google Analytics की सुविधा को फिर से चालू करें.

इसके अलावा, उपयोगकर्ता की सहमति मोड के विकल्पों के आधार पर, Analytics कलेक्शन को फिर से चालू करना है या नहीं, यह तय करने के लिए UMP_consentModeValues लोकल स्टोरेज की कुंजी पढ़ें. वैल्यू, चार अंकों वाली स्ट्रिंग होती है.

  • पहले अंक से, ad_storage के मकसद की वैल्यू का पता चलता है
  • दूसरा अंक, ad_user_data पैरामीटर की वैल्यू दिखाता है
  • तीसरा अंक, विज्ञापन को पसंद के मुताबिक बनाने के मकसद की वैल्यू दिखाता है
  • चौथा अंक, analytics_storage के मकसद की वैल्यू दिखाता है

यहां दी गई टेबल में, हर अंक के लिए संभावित वैल्यू के बारे में बताया गया है:

मान मतलब
0 फ़िलहाल, कोई वैल्यू उपलब्ध नहीं है.
1 उपयोगकर्ता GRANTED इस मकसद के लिए.
2 उपयोगकर्ता DENIED इस मकसद के लिए.
3 यह उपयोगकर्ता, सहमति मोड का इस्तेमाल नहीं करता.
4 इस मकसद के लिए, सहमति मोड कॉन्फ़िगर नहीं किया गया है.

यहां दिए गए उदाहरण में, UMP_consentModeValues को पार्स किया गया है. साथ ही, अगर सभी मकसद GRANTED हैं या लागू नहीं होते हैं, तो Google Analytics को चालू किया गया है. इसके अलावा, Analytics के डेटा कलेक्शन को बंद किया गया है:

Java

// Helper function that sets Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private void maybeReEnableAnalyticsCollection() {
  String consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null);
  if (shouldReEnableAnalyticsCollection(consentModeValues)) {
    firebaseAnalytics.setAnalyticsCollectionEnabled(true);
  } else {
    firebaseAnalytics.setAnalyticsCollectionEnabled(false);
  }
}

// Helper function to determine whether Analytics collection should be enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private boolean shouldReEnableAnalyticsCollection(String consentModeValues) {
  if (consentModeValues.isEmpty()) {
    return false;
  }
  for (int i = 0; i < consentModeValues.length(); i++) {
    char consentModeValue = consentModeValues.charAt(i);
    switch (consentModeValue) {
      case '0':
        // Consent mode data not ready yet.
        return false;
      case 1:
        // Consent mode is granted for this purpose.
        break;
      case '2':
        // Consent is denied for this consent mode purpose.
        return false;
      case '3':
        // Consent does not apply for this purpose at this time.
        break;
      case '4':
        // Consent mode is not configured for this purpose.
        break;
      default:
    // Unexpected value encountered.
        return false;
    }
  }
  // If all checks pass, re-enable Analytics collection.
  return true;
}

Kotlin

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private fun maybeReEnableAnalyticsCollection() {
    val consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null)
    if (shouldReEnableAnalyticsCollection(consentModeValues)) {
        firebaseAnalytics.setAnalyticsCollectionEnabled(true)
    }
}

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private fun shouldReEnableAnalyticsCollection(consentModeValues: String?): Boolean {
    if (consentModeValues.isNullOrEmpty()) {
        return false
    }
    for (consentModeValue in consentModeValues) {
        when (consentModeValue) {
            '0' -> {
                // Consent mode data not ready yet.
                return false
            }
            '1' -> {
                // Consent mode is granted for this purpose.
            }
            '2' -> {
                // Consent is denied for this consent mode purpose.
                return false
            }
            '3' -> {
                // Consent does not apply for this purpose at this time.
            }
            '4' -> {
                // Consent mode is not configured for this purpose.
            }
            else -> {
                // Unexpected value encountered.
                return false
            }
        }
    }
    // If all checks pass, can re-enable Analytics collection.
    return true
}

Swift

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private func maybeReEnableAnalyticsCollection() {
  let consentModeValues = userDefaults.string(forKey: "UMP_consentModeValues")
  if shouldReEnableAnalyticsCollection(consentModeValues) {
      Analytics.setAnalyticsCollectionEnabled(true)
  }
}

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.   
private func shouldReEnableAnalyticsCollection(_ consentModeValues: String?) -> Bool {
  guard let consentModeValues = consentModeValues, !consentModeValues.isEmpty else {
    return false
}

for consentModeValue in consentModeValues {
  switch consentModeValue {
    case "0":
      // Consent mode data not ready yet.
      return false
    case "1":
      // Consent mode is granted for this purpose.
      break
    case "2":
      // Consent is denied for this consent mode purpose.
      return false
    case "3":
      // Consent does not apply for this purpose at this time.
      break
    case "4":
      // Consent mode is not configured for this purpose.
      break
    default:
      // Unexpected value encountered.
      return false
    }
  }
  // If all checks pass, can re-enable Analytics collection.
  return true
}

Objective-C

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
- (void)maybeReEnableAnalyticsCollection {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *consentModeValues = [defaults stringForKey:@"UMP_consentModeValues"];
    if ([self shouldReEnableAnalyticsCollection:consentModeValues]) {
        [FIRAnalytics setAnalyticsCollectionEnabled:YES];
    }
  }

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
- (BOOL)shouldReEnableAnalyticsCollection:(NSString *)consentModeValues {
    if (!consentModeValues || [consentModeValues length] == 0) {
        return NO;
    }

    for (NSUInteger i = 0; i < [consentModeValues length]; i++) {
      unichar consentModeValue = [consentModeValues characterAtIndex:i];
      switch (consentModeValue) {
          case '0':
              // Consent mode data not ready yet.
              return NO;
          case '1':
              // Consent mode is granted for this purpose.
                break;
          case '2':
              // Consent is denied for this consent mode purpose.
              return NO;
          case '3':
              // Consent does not apply for this purpose at this time.
              break;
          case '4':
              // Consent mode is not configured for this purpose.
              break;
          default:
              // Unexpected value encountered.
              return NO;
          }
      }
      // If all checks pass, can re-enable Analytics collection.
      return YES;
  }

maybeReEnableAnalyticsCollection को कॉल करें, जब:

  • सहमति की जानकारी अपडेट की जाती है
  • सहमति ली गई है.