# Deprecated: Manual setup

{% hint style="success" %}
**Didomi now supports native integrations with Firebase and** [**AAP SDKs**](https://support.google.com/google-ads/answer/12961402?hl=en)**. Use** [**this new guide**](https://developers.didomi.io/cmp/mobile-sdk/google-consent-mode/google-consent-mode-implementation-steps) **for a simplified setup.**

**In the code of your Mobile app make sure you no longer** [**setConsent**](#update_consent) **for Google consent mode.**
{% endhint %}

{% hint style="danger" %}
**The current document is deprecated and WILL SOON BE DELETED.**
{% endhint %}

Google Analytics offers *Consent Mode v2* to adjust how your SDK behaves based on the consent status of your users. You can indicate whether consent has been granted for Analytics and Ads cookies. To implement *Consent Mode* v2 for apps, use the Google Analytics for Firebase SDK to set default consent values and use the `setConsent` method to update these values programmatically, based on in-app user consent. To learn more, see [Consent Mode](https://support.google.com/analytics/answer/9976101).

Google *Consent Mode* allows you to configure the status for the following parameters or Consent Types:

* `ANALYTICS_STORAGE`
* `AD_STORAGE`
* `AD_USER_DATA`
* `AD_PERSONALIZATION`

## Initial setup <a href="#initial_setup" id="initial_setup"></a>

By default, no Consent Type values are set. Follow the instructions below to change the default consent state for your app.

### Analytics storage <a href="#analytics_storage" id="analytics_storage"></a>

{% tabs %}
{% tab title="Android" %}
To disable **Analytics storage**, set the value of `google_analytics_default_allow_analytics_storage` to `false` in the `application` tag of your app's `AndroidManifest.xml` file. For example:

```xml
<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />
```

{% endtab %}

{% tab title="iOS" %}
To disable **Analytics storage**, set the value of `GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE` to `NO` in your app's `Info.plist` file:

```xml
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE</key>
<false/>
```

{% endtab %}
{% endtabs %}

### Ad storage <a href="#ad_storage" id="ad_storage"></a>

{% tabs %}
{% tab title="Android" %}
To disable **Ad storage**, set the value of `google_analytics_default_allow_ad_storage` to `false` in the `application` tag of your app's `AndroidManifest.xml` file. For example:

```xml
<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />
```

{% endtab %}

{% tab title="iOS" %}
To disable **Ad storage**, set the value of `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE` to `NO` in your app's `Info.plist` file:

```xml
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE</key>
<false/>
```

{% endtab %}
{% endtabs %}

### Ad user data

{% tabs %}
{% tab title="Android" %}
To disable **Ad user data**, set the value of `google_analytics_default_allow_ad_user_data` to `false` in the `application` tag of your app's `AndroidManifest.xml` file. For example:

```
<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />
```

{% endtab %}

{% tab title="iOS" %}
To disable **Ad user data**, set the value of `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA` to `NO` in your app's `Info.plist` file:

```xml
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA</key>
<false/>
```

{% endtab %}
{% endtabs %}

### Ad personalization

{% tabs %}
{% tab title="Android" %}
To disable **Ad personalization**, set the value of `google_analytics_default_allow_ad_personalization_signals` to `false` in the `application` tag of your app's `AndroidManifest.xml` file. For example:

```
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />
```

{% endtab %}

{% tab title="iOS" %}
To disable **Ad personalization**, set the value of `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS` to `NO` in your app's `Info.plist` file:

```xml
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS</key>
<false/>
```

{% endtab %}
{% endtabs %}

## Update consent <a href="#update_consent" id="update_consent"></a>

To update the Consent Type values after an app has launched, call the `setConsent` method of the `Analytics` library.

The value set by the `setConsent` method persists across app executions and overrides the default values configured through the `Info.plist` and `AndroidManifest.xml` files . The value remains in that state until `setConsent` is called again, even if a user closes and reopens the app. Calling `setConsent` to modify Ad storage does not change the state of Analytics storage or any other consent mode value.

The following example shows the `setConsent` method updating values for Analytics, Ad storage, Ad user data and Ad personalization to *granted* or *denied*:

{% tabs %}
{% tab title="Java" %}

```java
// Set consent types.
Map<ConsentType, ConsentSetting> consentMap = new EnumMap<>(ConsentType.class);
consentMap.put(ConsentType.ANALYTICS_STORAGE, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_STORAGE, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_USER_DATA, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_PERSONALIZATION, ConsentStatus.GRANTED|ConsentStatus.DENIED);

mFirebaseAnalytics.setConsent(consentMap);
```

{% endtab %}

{% tab title="Kotlin" %}

<pre class="language-kotlin"><code class="lang-kotlin"><strong>Firebase.analytics.setConsent {
</strong>    analyticsStorage = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adStorage = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adUserData = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adPersonalization = ConsentStatus.GRANTED|ConsentStatus.DENIED
}
</code></pre>

{% endtab %}

{% tab title="Swift" %}

```swift
Analytics.setConsent([
  .analyticsStorage: .granted|.denied,
  .adStorage: .granted|.denied,
  .adUserData: .granted|.denied,
  .adPersonalization: .granted|.denied,
])
```

{% endtab %}

{% tab title="Obj-C" %}

```objectivec
[FIRAnalytics setConsent:@{
  FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdStorage : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdUserData : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdPersonalization : FIRConsentStatusGranted|FIRConsentStatusDenied,
}];
```

{% endtab %}
{% endtabs %}

### Get and apply user consent for Google

To update the Consent Type values after a user has provided their consent choices, use the [`setConsent`](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#public-void-setconsent-mapfirebaseanalytics.consenttype,-firebaseanalytics.consentstatus-consentsettings) method of the `Analytics` library as shown in the examples below.

The status of Google Vendor with ID `google` will be used to get the value for:

* `AD_STORAGE`
* `AD_USER_DATA`
* `AD_PERSONALIZATION`

The status of Google Analytics Vendor with ID `c:googleana-4TXnJigR` will be used to get the value for:

* `ANALYTICS_STORAGE`

The following examples show how to get the user status from the Didomi SDK and apply that status to Google *Consent Mode*.

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // The status of the user has changed
        UserStatus userStatus = Didomi.getInstance().getUserStatus();
        
        // Ids of enabled vendors
        Set<String> enabledVendorIds = userStatus.getVendors().getGlobal().getEnabled();
        
        // Search for Google vendors
        ConsentStatus googleAnalyticsStatus = enabledVendorIds.contains("c:googleana-4TXnJigR") ? ConsentStatus.GRANTED : ConsentStatus.DENIED
        ConsentStatus googleStatus = enabledVendorIds.contains("google") ? ConsentStatus.GRANTED : ConsentStatus.DENIED
        
        // Set consent types
        Map<ConsentType, ConsentSetting> consentMap = new EnumMap<>(ConsentType.class);
        consentMap.put(ConsentType.ANALYTICS_STORAGE, googleAnalyticsStatus);
        consentMap.put(ConsentType.AD_STORAGE, googleStatus);
        consentMap.put(ConsentType.AD_USER_DATA, googleStatus);
        consentMap.put(ConsentType.AD_PERSONALIZATION, googleStatus);
        
        mFirebaseAnalytics.setConsent(consentMap);
    }
})
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun consentChanged(event: ConsentChangedEvent) {
        // The status of the user has changed
        val userStatus = Didomi.getInstance().userStatus
        
        // Ids of enabled vendors
        val enabledVendorIds = userStatus.vendors.global.enabled
        
        // Search for Google vendors
        val googleAnalyticsStatus = if (enabledVendorIds.contains("c:googleana-4TXnJigR")) ConsentStatus.GRANTED else ConsentStatus.DENIED
        val googleStatus = if (enabledVendorIds.contains("google")) ConsentStatus.GRANTED else ConsentStatus.DENIED
        
        // Set consent types
        Firebase.analytics.setConsent {
            analyticsStorage = googleAnalyticsStatus
            adStorage = googleStatus
            adUserData = googleStatus
            adPersonalization = googleStatus
        }
    }
})
```

{% endtab %}

{% tab title="Swift" %}

```swift
let didomiEventListener = EventListener()
didomiEventListener.onConsentChanged = { event in
    // The status of the user has changed
    let userStatus = Didomi.shared.getUserStatus()
    
    // Ids of enabled vendors
    let enabledVendorIDs = userStatus.vendors.global.enabled
    
    // Search for Google vendors
    let googleAnalyticsStatus: FirebaseAnalytics.ConsentStatus = enabledVendorIDs.contains("c:googleana-4TXnJigR") ? .granted : .denied
    let googleStatus: FirebaseAnalytics.ConsentStatus = enabledVendorIDs.contains("google") ? .granted : .denied
    
    // Set consent types
    Analytics.setConsent([
      .analyticsStorage: googleAnalyticsStatus,
      .adStorage: googleStatus,
      .adUserData: googleStatus,
      .adPersonalization: googleStatus
    ])
}
```

{% endtab %}

{% tab title="Obj-C" %}

```objectivec
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnConsentChanged:^(enum DDMEventType event) {
    // The status of the user has changed
    Didomi *didomi = [Didomi shared];
    DDMUserStatus *userStatus = [didomi getUserStatus];
    
    // Ids of enabled vendors
    NSSet *enabledVendorIDs = [[[userStatus vendors] global] enabled];
    
    // Search for Google vendors
    FIRConsentType googleAnalyticsStatus = [enabledVendorIDs containsObject:@"c:googleana-4TXnJigR"] ? FIRConsentStatusGranted : FIRConsentStatusDenied;
    FIRConsentType googleStatus = [enabledVendorIDs containsObject:@"google"] ? FIRConsentStatusGranted : FIRConsentStatusDenied;
    
    // Set consent types
    [FIRAnalytics setConsent:@{
      FIRConsentTypeAnalyticsStorage : googleAnalyticsStatus,
      FIRConsentTypeAdStorage : googleStatus,
      FIRConsentTypeAdUserData : googleStatus,
      FIRConsentTypeAdPersonalization : googleStatus
    }];
}];
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/cmp/mobile-sdk/google-consent-mode/deprecated-manual-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
