androidgoogle-analyticsfirebase-analytics

Firebase Analytics first_open and session_start events not sent when consent granted


In our project we switched to Consent Mode v2 and therefore set the initial consent of analytics_storage, ad_storage, ad_user_data and ad_personalization_signals to false. After this change we were no longer able to track first_open and session_start events, even after granting consent later.

This issue was already raised in the firebase-android-sdk project (https://github.com/firebase/firebase-android-sdk/issues/5697) and on the Google Analytics Support page (https://support.google.com/analytics/thread/257853980/firebase-analytics-first-open-and-session-start-events-not-sent-when-consent-granted?hl=en).


Solution

  • We found an answer to this problem, at least for our project. Maybe it will help someone else. On starting the app, our CMP tool called a custom disableFirebaseTracking() method. Inside this method, the reference to the FirebaseAnalytics instance was set to null, so that the instance was garbage collected

    firebaseAnalytics = FirebaseAnalytics.getInstance(context)
    firebaseAnalytics = null
    

    Because of this, all locally stored Tracking events, e.g. first_open, were deleted and didn't show up after granting the consent.