Google Analytics is a great tool for tracking metrics about how users are interacting with your Android applications.

It is so simple to set up that I highly recommend you use it in your Android development. In this tutorial, I describe how to set up and use Google Analytics for Android and HTML 5 Base Native Application.

Like Phonegap HTML5 mobile framework Using To Developing Android Application. For Build With Android Studio. Now I’ve gleaned from it.

Google Analytics setup

First, you must sign up to use Google Analytics through an existing Google account. Next, you must create an account for your application.

Select [Admin] Tab  for Administration Area  [Property]

By clicking drop-down box  –>Create new property
for New Property > What would you like to track?  Select [ Mobile apps ]
Setting up your property  > App Name. Here write your android application  name

set up with Android Studio

Now In order to set up Google Analytics inside your Android application, download the zip file for Android. Extract the file once it downloads and copy the jar file inside into the lib folder of your Android project.

(If a lib folder does not already exist, simply create one.) Now, I need the java build path. see here if you don’t know how to build path in android studio if you’re using Android Studio, follow these steps:

  • Select  File -> Project structure -> Modules -> Sources -> Add content root

Updating AndroidManifest.xml

Next, add the following permissions to your application’s Manifest.xml file:
 < android:name="android.permission.INTERNET" />
 < android:name="android.permission.ACCESS_NETWORK_STATE" />

Adding EasyTracker methods

Add the send methods to the onStart() and onStop() methods of each of your Activities. Creat a myTrackedActivity.java class file.

select [src] folder right-click New > Java Class . Copy & Past Blow Flowing Code  as in the following example:

import android.app.Activity;
import com.google.analytics.tracking.android.EasyTracker;
/**
* Created by bijoy .
*/
public class myTrackedActivity extends Activity {
@Override
public void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
public void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
}

Creating your analytics.xml file

When you use EasyTracker, global configuration settings are managed using resources defined in XML.

Create a file called analytics.xml in your project’s res/values directory and add the following resources code in analytics.xml file :

Now that your project is set up to start using Google Analytics. Doing so will prevent you from seeing any data in your reports.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
jenifer david Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
jenifer david
Guest
jenifer david

Appreciating the persistence you put into your blog and detailed information you provide.