Hi, everyone we go through a lot of apps and websites these days, they may be related to different domains, may be no way related to each other but every website or app deals with a important topic called as “analytics”.
Today we are dealing with google analytics android tutorial, Yes this may not be a new word for few but in this google analytics android tutorial i am targeting who are new to this terminology.
Analytics
Analytics is the phenomena where the statistics of the app or website is closely observed so that the audience, their interest can be noticed by respective admins.
So here lies the point that analytics not only helps to know the audience count but also improves the overall performance of app/website in terms of tracking bugs in time as well getting notified with reviews, and few more which may help development.
Much More Simple
So now have you ever noticed popular website like Flipkart, Amazon, snapdeal, and many more shopping portals and their apps starts showing you products which you have stared at, purchased, or looking for lot once you visited them.
Now, i think you understood now that by this simple example its a part of analytics and also its not that simple as it appears but lets see it in our coming tutorial.
Is this for everyone ?
When you are trying to build an app/website, ok think its done and now you want to know who visited them and what have they been going through, how much time they are spending on your site exactly on which page this is what we are going to deal with.
Also from where i.e, country, device, service provider, gender, number of visits per hour, day, week, monthly like what not you can know all these scenarios and much more google analytics android tutorial.
Let’s Get started :
Are you planning to start developing a new app or already having an app so this android app development tutorial is very much useful for you, lets get started today we will deal with a simple example by which we can trace out analytics of our app.
We will be using Google Firebase for tracing out app’s analytics.
Visit https://firebase.google.com to get started
Then login in with your credentials
Then Add a project
Select Android Project
Add Firebase to your android app by mentioning package name, app name, and SHA-1.
The process of retrieving SHA-1 key is shown below
Download the json file and add it to your android studio project.
Then add dependencies
build.gradle (Project: Firebase Tutorial)
1 2 3 4 5 6 7 8 |
dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' } |
build.gradle (Module: app)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.google.firebase:firebase-core:10.0.1' compile 'com.google.android.gms:play-services:10.0.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' testCompile 'junit:junit:4.12' apply plugin: 'com.google.gms.google-services' } |
In MainActivity add FirebaseAnalytics as
1 2 3 4 5 |
private FirebaseAnalytics firebaseAnalytics; |
Then initialize
1 2 3 4 5 |
firebaseAnalytics = FirebaseAnalytics.getInstance(this); |
Add a log event
1 2 3 4 5 |
firebaseAnalytics.logEvent("MainActivity", new Bundle()); |
Don’t forget to add internet permission to your manifest file
1 2 3 4 5 |
<uses-permission android:name="android.permission.INTERNET" /> |
And that’s it now after 24 hours you will be able to track your audience
Try it out and ask me below in comment section if you have any queries.
If you require project file comment below.
Share it to your friends if you really like it.