Google Analytics


 

Steps to do before:
  1. Sign up here and login. Then, click on Admin in the navigation bar.
  2. Click on the list of properties, and choose “Create new property” under property tab.
  3. You have now to indicate that the new property will track data from a Mobile app. Give it a name, a timezone, and an industry category related to your app.
  4. Get the Tracking ID, something like UA-xxxxxxxx-y.

 

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, MyAnalytics.java and add following code :

Step 5 : Create a new xml file under xml folder, app_tracker.xml and copy paste this code:

Step 6 : Create a new xml file under xml folder, ecommerce_tracker.xml and copy paste this code:

Step 7 : Create a new xml file under xml folder, global_tracker.xml and copy paste this code:

Step 8 : Open AndroidManifest.xml and add following code :

Step 9 : Open build.gradle(Module: app) and add following code :

ScreenShots:

 analytics

Download_button