Quantcast
Channel: Droid App » Android Development
Viewing all articles
Browse latest Browse all 10

Android Dev: Adding Google Analytics Tracking

$
0
0
{lang: 'en-GB'}

First post in quite a while. Quick one, you can use Google Analytics to track use of your application. Here’s the quickest way using the EasyTracker.

First download the

Add this to your projects libs folder and add to the build path (right click, add to build path).

Now you need to create an entry in you Google Analytics account for the app. Give it a meaningful name and a url such as http://yourappname.yourdomain.com (this doesn’t need to exist).

Get the “Property Id” from your new entry (it will start UA….).

You now need to create an xml file called GoogleAnalytics under res/values/ :

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <!-- Replace placeholder GA API key with a real one. -->
  <string name="ga_api_key">UA-xxxxxx-15</string>

  <bool name="ga_debug">true</bool>
  <bool name="ga_dryRun">false</bool>
  <bool name="ga_auto_activity_tracking">true</bool>
  
  <!-- We want to see simple, descriptive names in the Google Analytics reports
       instead of the canonical name for each Activity. 
  <string name="com.example.android.notepad.NoteEditor">NoteEditor</string>
  <string name="com.example.android.notepad.TitleEditor">TitleEditor</string>
  <string name="com.example.android.notepad.NotesList">ListOfNotes</string>-->
</resources>

You will need to change the API key to your UA number.

Now that that is setup the rest is VERY easy.

In your Activity that you want to track simply change “extends Activity” to “extends TrackedActivity”. You will need to import the library (Ctrl+Shift+O in Eclipse will sort this for you).

Hope this helps someone.

The post Android Dev: Adding Google Analytics Tracking appeared first on Droid App.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images