We know how much is Google analytics is important for our website to track users and session and lots of other things. Integration of Google analytics in a website is very easy you simply login to Google analytics and get analytics code and paste in your website page. Now in this post I like to explain you how to integrate Google analytics in your Android application. When you integrate analytics in your application you get various information like No. of users are active in your application, Location of users, Version which are they using and also some other information.

Integrating Google Analytics in Android Application

Step 1. Go to Firebase console and create a new project.

Step 2. Create new project name your project and select country and click on create the project.

Setup Firebase account

Step 3. Now click on Add Firebase to your Android app and name your application package name and your system SHA1 here 

Create config file android firebase

Step 4.  Now once you complete above step google-services.json is automatically downloaded on your browser if not you can download on link

Get Google service.json in firebase

Setup Google Analytics in App

Step 1. Now you need to move downloaded google-service.json file in your application Plz paste into specific location please follow bellow image

Add google-service.json file in android application

Step 2. Now open your Project Gradle and add google service library in it

Step 3. Now open your Application gradle and Google analytics library in it apply plugin as shown bellow.

Step 4. Now create Application class which extends Application in this class we initialize GoogleAnaytics as shown bellow.

Step 5. Now you need to call this in your manifest.xml file as shown bellow

Step 6. You can call analytic inside your activity using bellow code

That’s all from mobile application part.

Enable mobile analytics reporting on Google Analytics

Step 1. Login to your google analytics.

Step 2. Click on Admin button at bottom of page

Link firebase application in google analytics

Step 3. After click on admin go to property and add new property 

Add firebase application in google analytics

Step 4. You need to select Mobile App and Firebase App and select your application

Select firebase application in google analytics

And save now you can view your analytics in firebase to view analytics you need to select your application

View mobile application analytics

Now go to Streamview menu and click on it now you check active users as shown bellow

View current active user of android application on google analytics

That’s all if you follow all steps I am sure you get your users info on google analytics.

I am already using above code in one of my e-commerce offloo.com application.

Hope this blog help you. Please like and share my blog if its help you :).