Getting 'not set'/garbage value for Google Ad Id (GAID) in Firebase analytics when set as custom user property
Asked Answered
M

0

0

I fetch and send GAID from Splash activity of my application. I found the GAID alright in debug mode on my physical device. I also tested using Firebase debugging tool and got proper GAID value as a custom user property data (as intended). However, since the full release of my app on playstore, most data are showing either 'not set' or the default 00000000-0000-0000-000000000000 as the GAID sent from user devices.

enter image description here

What seems to be the issue? It has been more than a month since the full release, and the situation is still the same. Following is what I have done to get and set the GAID as a custom user property:

CoroutineScope(Dispatchers.IO).launch {
        var idInfo: AdvertisingIdClient.Info? = null
        try {
            idInfo = AdvertisingIdClient.getAdvertisingIdInfo(context.applicationContext)
        } catch (e: GooglePlayServicesNotAvailableException) {
            e.printStackTrace()
        } catch (e: GooglePlayServicesRepairableException) {
            e.printStackTrace()
        } catch (e: IOException) {
            e.printStackTrace()
        }
        var advertId: String? = null
        try {
            advertId = idInfo?.id
        } catch (e: NullPointerException) {
            e.printStackTrace()
        }
        Log.d(TAG, "onCreate:AD ID $advertId")
        dispatchUserProperty(FbUserProperty.DEVICE_AD_ID, advertId)
}

/**
 * Method to dispatch user property
 */
private fun dispatchUserProperty(key: String, value: String?) {
    if (!CommonUtilsOld.isFirebaseAppInitialized()) return
    Log.d(TAG, "dispatchUserProperty() called with: key = [$key], value = [$value]")
    FbaController.setUserProperty(key, value)
}

/**
 * Method to check if firebase app has been initialized
 */
public static boolean isFirebaseAppInitialized(){
    return !FirebaseApp.getApps(MainApplication.getInstance()).isEmpty();
}

I have added the following dependency in app level gradle:

implementation 'com.google.android.gms:play-services-ads:22.1.0'

And added the following permission in the manifest:

<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
Manageable answered 6/5, 2024 at 16:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.