Android Firebase Analytics Set up

 Connect Android Application to Firebase Analytics 

Step 1: Add the Analytics SDK to your app (gradle)

dependencies {

    // Import the BoM for the Firebase platform

    implementation platform('com.google.firebase:firebase-bom:26.1.1')


    // Declare the dependency for the Analytics library

    // When using the BoM, you don't specify versions in Firebase library dependencies

    implementation 'com.google.firebase:firebase-analytics'

}


Step 2: Code to write to Analytics in your Android app (custom event)

val analytics : FirebaseAnalytics =  FirebaseAnalytics.getInstance(this)

val bundle = Bundle()
bundle.putString("First_Category", "First_catValue")
bundle.putString("sub_Cat", "sub_CatValue")
analytics.setDefaultEventParameters(null)
analytics.logEvent("My_Custom_Event", bundle)

Step 3: You will see these in Events on the firebase console however can take 24 hours to show

Step 4: Set up Analytics DEBUG VIEW on Firebase console for developers 

1. Set up the command for adb - go to your environement variables and create a new path which links toyour andorid adb. Example: C:\Program Files (x86)\Android\android-sdk\platform-tools

2. In the terminal point to your project using this command:

adb shell setprop debug.firebase.analytics.app <package_name>

Example: adb shell setprop debug.firebase.analytics.app com.gareth.gym

To disbale this:

adb shell setprop debug.firebase.analytics.app .none.

3. Logging data on Android terminal - enable Firebase logs:

shell setprop log.tag.FA VERBOSE

adb shell setprop log.tag.FA-SVC VERBOSE

adb logcat -v time -s FA FA-SVC

4. On your device which i running the app: 

GO TO SETTINGS -> DEVELOPER OPTIONS -> SELET APP TO BE DEBUG -> com.gareth.gym

Key point: You may need to run the app in debug mode.


Comments

Popular posts from this blog

Big O asymptotic analysis/Big O notation

Basic Overview of Microsoft Azure?

Understanding the basics of REST API with HTTP and JSON