mobile analytics android

14
MOBILE GOOGLE ANALYTICS A Quickstart for Android Prepared by: Michael Angelo M. Rivera Date: October 25, 2012

Upload: michael-angelo-rivera

Post on 27-Jan-2015

105 views

Category:

Documents


0 download

DESCRIPTION

quickstart for android some

TRANSCRIPT

Page 1: Mobile Analytics Android

MOBILE GOOGLE ANALYTICSA Quickstart for Android

Prepared by: Michael Angelo M. RiveraDate: October 25, 2012

Page 2: Mobile Analytics Android

What it does?

• The number of active users are using their applications.• From where in the world the application is being used.• Adoption and usage of specific features.• In-app purchases and transactions.• And many other useful metrics...

Page 3: Mobile Analytics Android

How to get it?

• Download the Google Analytics library for Android in resource website (Google it).

OR

• Update use the Android SDK Manager to get the Google Analytics SDK.• - Check the android-sdk/extras/google /*

Page 4: Mobile Analytics Android

Sign up for an account• Sign up for Google Analytics if you don't already have an

account.

• Create a new UA, also known as a Web property ID. Once you are signed into Google Analytics you will see a drop down list in the top right corner. Select "Create new account" and follow the steps provided. Google documentation suggests "using a fake but descriptive website URL (e.g. http://mymobapp.mywebsite.com)". Whatever you choose is entirely up to you.

• Write the UA or go back to your profile page to access it.

Page 5: Mobile Analytics Android

Add the GA library file

• In Eclipse right click on your project (control + click for OSX) and select Properties. Choose Java Build Path and then select the Libraries tab. Then you will need to select the Add External JARs button and navigate to where you saved the library on your computer.

Page 6: Mobile Analytics Android

Add permissions

• Add the following permissions to your AndroidManifest.xml file.

android.permission.INTERNET android.permission.ACCESS_NETWORK_STATE

Page 7: Mobile Analytics Android

How to use it ?• Obtain tracker instance and start in manual mode, usually

done in onCreate(Bundle savedInstanceState)

mAnalyticsTracker = GoogleAnalyticsTracker.getInstance();

mAnalyticsTracker.start("insert_UA", this);

*If you start the tracker in manual mode you will need to call dispatch() to fire off the tracking events. This call is not required if you passed a time interval to the start call.

mAnalyticsTracker.dispatch();

Page 8: Mobile Analytics Android

How to use it ?• You can also start the tracker with a dispatch interval by

specifying a seconds parameter. The following code will dispatch request every 60s.

mAnalyticsTracker.start("insert_UA", 60, this);

*insert_UA - is your web property ID from your profile that you created.

Page 9: Mobile Analytics Android

How to use it ?• The Google documentation suggests using

trackPageView as the best way to track which areas of your application are being viewed by users.

Say we want to track when the users view the help screen, we simply pass HelpScreen.

mAnalyticsTracker.trackPageView("/HelpScreen");

*The string value passed to trackPageView is entirely up to you.

Page 10: Mobile Analytics Android

How to use it ?• Tracking click events:

public void sayHelloButtonPressed(View v) {

welcomeView.setText("Welcome, user!");

tracker.trackEvent("FirstActivity", "sayHello", "", -1);

}

The trackEvent ,takes four parameters: the event’s category, an action, a label, and a value. In the Google Analytics interface events are grouped by categories, and additionally may contain per-event labels

Page 11: Mobile Analytics Android

How to use it ?• Finally, remember to stop the tracker when you no longer

need it's services.

mAnalyticsTracker.stop();

*usually called in your onDestroy()

Page 12: Mobile Analytics Android

Quick overview for iOS• Drag GANTracker.h and libGoogleAnalytics.a from the

SDK’s library directory into your project. • Add the CFNetwork framework and link against

libsqlite3.0.dylib.• Initialize the tracker. Since we want to start tracking

impressions and events immediately, the most logical place to put this initialization is in our application’s AppDelegate. Be sure to import GANTracker.h in your implementation file

• Same thing trackPageView and or trackEvents• Stop the tracker in your dealloc method:

(No sample codes since, I’m not an iOS dev, so I guess you’ll understand anyway)

Page 13: Mobile Analytics Android

Lastly check the Dashboard• Log in to Google Analytics website and see what is

happening.