Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini ditujukan untuk developer yang menggunakan Google Analytics for Firebase SDK di aplikasi mereka dan ingin mengintegrasikan mode izin. Untuk mempelajari pengantar mode izin, baca artikel Ringkasan mode izin.
Google Analytics menawarkan mode izin untuk menyesuaikan perilaku SDK Anda berdasarkan status izin pengguna. Lihat jenis izin untuk semua parameter yang tersedia.
Sebelum memulai
Sebelum dapat mengelola izin pengguna, Anda perlu menerapkan:
Tambahkan pasangan nilai kunci mode izin. Kunci mendeskripsikan jenis izin dan nilai menunjukkan status izin. Nilai dapat berupa true, yang berarti izin diberikan, atau false, yang berarti izin ditolak. Tetapkan nilai berikut ini:
Untuk memperbarui nilai izin setelah aplikasi diluncurkan, panggil metode setConsent.
Nilai yang ditetapkan oleh metode setConsent akan menggantikan setelan default dan akan tetap ada di seluruh eksekusi aplikasi. Nilai tersebut akan tetap memiliki status tersebut hingga setConsent dipanggil lagi, bahkan jika pengguna menutup dan membuka kembali aplikasi. setConsent hanya akan memperbarui parameter yang Anda tentukan.
Jika pengguna membatalkan izin yang diberikan sebelumnya untuk penyimpanan Analisis atau Iklan, Google Analytics akan menghapus semua properti pengguna, termasuk izin untuk ad personalization.
Guna mempertahankan pilihan izin pengguna untuk personalisasi iklan, pulihkan nilai sebelumnya untuk personalisasi iklan menggunakan setConsent(Swift | Obj-C).
Contoh berikut menampilkan metode setConsent yang memperbarui berbagai nilai izin ke granted:
Sebagai bagian dari komitmen berkelanjutan Google terhadap ekosistem periklanan digital yang menjaga privasi, kami akan memperketat pemberlakuan kebijakan izin pengguna Uni Eropa kami.
Pengguna mode izin harus mengirim dua parameter baru selain penyimpanan iklan dan penyimpanan analisis:
Perbarui info.plist aplikasi Anda untuk menyertakan:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-04-17 UTC."],[[["\u003cp\u003eThis guide helps Firebase developers integrate consent mode to control data collection based on user consent, covering both basic and advanced implementation options.\u003c/p\u003e\n"],["\u003cp\u003eBefore setup, ensure you've implemented the Google Analytics for Firebase SDK and a consent settings banner or CMP.\u003c/p\u003e\n"],["\u003cp\u003eTo set up consent mode, define default consent states in your app's info.plist file and use the \u003ccode\u003esetConsent\u003c/code\u003e method to dynamically update consent values based on user choices.\u003c/p\u003e\n"],["\u003cp\u003eConsent mode v2 introduces two additional parameters, \u003ccode\u003ead_user_data\u003c/code\u003e and \u003ccode\u003ead_personalization\u003c/code\u003e, to comply with Google's updated EU user consent policy, requiring updates to your app's info.plist and consent calls.\u003c/p\u003e\n"],["\u003cp\u003eVerify your implementation by checking the Xcode debug console for consent settings like \u003ccode\u003ead_storage\u003c/code\u003e, \u003ccode\u003eanalytics_storage\u003c/code\u003e, \u003ccode\u003ead_user_data\u003c/code\u003e, and \u003ccode\u003ead_personalization\u003c/code\u003e.\u003c/p\u003e\n"]]],["Developers integrate consent mode with the Google Analytics for Firebase SDK to manage user consent. Key actions involve setting default consent states in the `info.plist` file using keys like `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE` with `true` or `false` values, which now include `ad_user_data` and `ad_personalization`. The `setConsent` method updates consent after app launch, overriding defaults and persisting across sessions. Upgrading to consent mode v2 requires adding the two new consent parameters to both `info.plist` and `setConsent` calls. Verification is done via the Xcode debug console, checking for specific consent parameters.\n"],null,["# Set up consent mode for apps\n\n\u003e This page is for developers that use the Google Analytics for Firebase SDK in\n\u003e their app and want to integrate consent mode. For an introduction to consent\n\u003e mode, read [Consent mode\n\u003e overview](/tag-platform/security/concepts/consent-mode).\n\nGoogle Analytics offers consent mode to adjust how your SDK behaves based on the\nconsent status of your users. You can implement consent mode in a basic or\nadvanced way. If you aren't sure whether to implement basic or advanced consent\nmode, learn more about [basic versus advanced consent\nmode](/tag-platform/security/concepts/consent-mode#basic-vs-advanced) and check\nwith your company's guidelines. \nAdvanced consent mode Basic consent mode \niOS Android\n| **Important** : Consent mode for apps was updated Oct 30th 2023 and now contains two additional parameters. If you already use consent mode, [upgrade to consent mode v2](#upgrade-consent-v2). Learn more about Google's [Updates to consent mode for traffic in European Economic Area (EEA)](https://support.google.com/tagmanager/answer/13695607).\n\nBefore you begin\n----------------\n\nBefore you can manage user consent, you need to implement:\n\n- [Google Analytics for Firebase SDK](https://firebase.google.com/docs/analytics)\n- A consent settings banner to capture user consent\n\n | **Tip:** If you don't want to implement consent settings yourself, consider using a consent management platform (CMP).\n\nSet up consent mode\n-------------------\n\nTo set up consent mode, you need to:\n\n1. [Set the default consent state](#default-consent).\n\n### Set the default consent state\n\nBy default, no consent mode values are set. To set the default consent state for\nyour app:\n\n1. Open your app's [info.plist](https://developer.apple.com/documentation/bundleresources/information_property_list) file.\n2. Add the consent mode key-value pairs. The key describes the [consent\n type](/tag-platform/security/concepts/consent-mode#consent-types) and the\n value indicates consent state. Values can either be `true`, meaning consent\n was granted, or `false`, meaning consent was denied.\n\n In accordance with the updates to consent mode for traffic in\n European Economic Area (EEA), a value of `eu_consent_policy` can be set\n for `ad_user_data` and `ad_personalization`, meaning consent is denied only\n for users in regions subject to the EU User Consent Policy.\n\n Set the following:\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS`\n3. Save your changes. Next, implement the mechanism to update consent values.\n\nFor example, to set all grant consent for all parameters by default: \n\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS\u003c/key\u003e \u003ctrue/\u003e\n\n### Update consent\n\nTo update consent values after an app has launched, call the\n[`setConsent`](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#setConsent) method.\n\nThe value set by the `setConsent` method overrides the default setting and\npersists across app executions. The value remains in that state until\n`setConsent` is called again, even if a user closes and reopens the app.\n`setConsent` only updates the parameters you specify.\n\u003e If a user withdraws their previously given consent for Analytics or Ad\n\u003e storage, Google Analytics deletes all user properties, including consent for\n\u003e [`ad_personalization`](https://developers.google.com/tag-platform/security/concepts/consent-mode#consent-type).\n\u003e To preserve the user's consent choice for ad personalization, restore the\n\u003e previous value for ad personalization using `setConsent`\n\u003e\n\u003e ([Swift](https://firebase.google.com/docs/reference/swift/firebaseanalytics/api/reference/Categories/FIRAnalytics(Consent)#setconsent_:)\n\u003e \\| [Obj-C](https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#+setconsent:))\n\u003e .\n\nThe following example shows the `setConsent` method updating the different\nconsent values to `granted`: \n\n### Swift\n\n Analytics.setConsent([\n .analyticsStorage: .granted,\n .adStorage: .granted,\n .adUserData: .granted,\n .adPersonalization: .granted,\n ])\n\n### Objective-C\n\n [FIRAnalytics setConsent:@{\n FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdUserData : FIRConsentStatusGranted,\n FIRConsentTypeAdPersonalization : FIRConsentStatusGranted,\n }];\n\nIf a user decides to revoke their consent, make sure you update the consent\nstates accordingly\n\n\nUpgrade to consent mode v2\n--------------------------\n\nAs a part of Google's ongoing commitment to a privacy-safe digital advertising\necosystem, we are strengthening the enforcement of our [EU user consent\npolicy](https://www.google.com/about/company/user-consent-policy/).\n\nLearn more about Google's [Updates to consent mode for traffic in European\nEconomic Area (EEA)](https://support.google.com/tagmanager/answer/13695607).\n\nConsent mode users need to send two new parameters in addition to ad storage and\nanalytics storage:\n\n1. Update your app's info.plist to include:\n\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS\u003c/key\u003e \u003ctrue/\u003e\n\n2. Update your consent calls to include the parameters for ad user data and ad\n personalization:\n\n ### Swift\n\n Analytics.setConsent([\n .analyticsStorage: .granted,\n .adStorage: .granted,\n .adUserData: .granted,\n .adPersonalization: .granted,\n ])\n\n ### Objective-C\n\n [FIRAnalytics setConsent:@{\n FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdUserData : FIRConsentStatusGranted,\n FIRConsentTypeAdPersonalization : FIRConsentStatusGranted,\n }];\n\nVerify consent settings\n-----------------------\n\nYou can verify that your consent settings are working as intended by viewing the\nXcode debug console for your app.\n\nFollow these steps:\n\n1. [Enable verbose logging](https://firebase.google.com/docs/analytics/events?platform=ios#view_events_in_the_xcode_debug_console) on your device.\n2. In the Xcode debug console, look for:\n\n - `ad_storage`\n - `analytics_storage`\n - `ad_user_data`\n - `ad_personalization`\n\n For example, if Ad storage are enabled, you'll see the following message: \n\n ad_storage is granted."]]