Getting to Know Google Analytics SDK

If you make mobile apps or if you plan to have an app made for your business, you need to incorporate metrics. Google’s Analytics SDK gives you ways to do that for iOS (Apple’s iPhone and iPad) and Google’s Android platforms (see Figure 17-1) right from the beginning of your app process.

Figure 17-1: Android SDK Manager Log.

9781118236024-fg1701.eps

Some features you may find useful in Google Analytics SDK:

check.png Easy Tracker Library: This is where activity tracking comes in. I mention needing several lines of code to track activity of your users, but Google understands how difficult that can be and is working to make this feature easier to implement.

By using Google’s new libraries, you should be able to easily add the code snippets to your application to track activity, manage sessions, and push all calls to the Google Analytics tracker to the main UI Thread. This makes the SDK more responsive inside your app.

check.png Mobile Playground: This is more of an open-source tool than a feature. It accesses all the APIs for Google Analytics available for Mobile Application developers in one place. You can find it here:

http://code.google.com/p/analytics-api-samples/source/browse/#svn_trunk_src_tracking_mobile

check.png Better bug reporting and feature requesting: Google’s SDK team has created a whole website to help you address issues implementing SDK and its features. Find it here:

http://code.google.com/p/analytics-issues/issues/list

check.png Mobile tracking documentation: This is now easier to find as part of the overall Google Analytics documentation. You can find it here:

http://code.google.com/apis/analytics/docs/mobile/overview.html

check.png A whole new SDK version for both android and iOS: The new version of SDK for both mobile operating systems takes care of several issues, such as crashes and memory leaks.

Using Analytics SDK with Android

To get going with Google’s Analytics SDK for your Android app, simply follow these steps:

1. Download the Google Analytics SDK for Android from the following website:

http://code.google.com/mobile/analytics/download.html#Google_Analytics_SDK_for_Android

2. Add the library libGoogleanalytics.jar to your app project.

If this step leaves you scratching your head, don’t worry. Your app developer will know what this means.

3. Add these permissions to the Android manifest of your app:

<uses-permission android:name=”android.permission.INTERNET” />

<uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />

4. Create a distinctive website profile inside your Google Analytics account.

Most app developers simply create a false/fake website profile for this purpose.

Note: You’ll need the Web Property ID from this profile to track users anonymously. You’ll also need to disclose that you’re doing this to the users who sign up for and download your app.

5. Track your referring installs by making your links look like this:

http://market.android.com/search?q=pname:<package>&referrer=<referral>

You want to do this kind of tracking, especially if you have more than one way to download your app — for example, the market, an advertisement, or a website.

6. Go back into your app manifest and add this code as part of tracking referring installs:

<application>

<! -- Used for install referrer tracking (analytics) -- >

<receiver android:name=”com.google.android.apps.analytics.AnalyticsReceiver” android:exported=”true”>

<intent filter>

<action android:name=”com.android.vending.INSTALL_REFERRER” />

</intent-filter>

</receiver>

</application>

These steps should bring metrics into your Android app. You can also get more detailed and track user activities within your app, but that requires quite a few more lines of code and some advanced knowledge of the SDK — something your app developer will likely already know how to do.

tip.eps Go to this link to grab the downloads you need to work with the Android SDK and to see some advanced tutorials:

http://code.google.com/apis/analytics/docs/mobile/android.html

Using Analytics SDK with iPhone

To get going with Google’s Analytics SDK for your iPhone app, simply follow these steps:

1. Download the iOS Developer SDK from this link:

http://developer.apple.com/iphone

You must have Xcode 3.1 or greater and run Mac OS X 10.5.3 or greater.

2. Download Google Analytics for Mobile Apps iOS SDK from this link:

http://code.google.com/apis/analytics/docs/mobile/ios.html

3. Create a new iPhone OS project inside Xcode

4. Move (drag) GANTracker.h and libGoogleAnalytics.a out of the SDK Library directory and into your new project.

5. Make sure that you include CFNetwork framework in your new project.

6. Link against libsqlite3.0.dylib by scrolling through the list of Frameworks using Add Existing Framework feature and then clicking that library to add to your project.

7. After you add the code using the preceding steps, initialize the tracker with the UA-xxxxxx-xx Google Analytics ID for the account.

tip.eps Go to this link to grab the downloads you need to work with Google Analytics SDK for iOS and for instruction on some of the more advanced features:

http://code.google.com/apis/analytics/docs/mobile/ios.html

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.248.119