0

I want to import google analytics on my android application and my codes is

private GoogleAnalyticsTracker tracker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo);

    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.startNewSession(getString(R.string.analytics_id), this);
    tracker.trackPageView("/demo");
}

@Override
protected void onDestroy() {
    super.onDestroy();
    tracker.stopSession();
}

but it is not working... where am I doing wrong? Thanks... Note: I used tabactivity and each of tab codes like that...

ali
  • 161
  • 3
  • 10

2 Answers2

9

I found the answer from this blog. Hope it's helpful.
http://blog.blundellapps.com/google-analytics-common-problems-and-fixes/

Pang
  • 9,564
  • 146
  • 81
  • 122
ali
  • 161
  • 3
  • 10
  • 1
    Perfect, exactly what I had done right but found to be wrong. Replace “-” with an “en dash” character (–, &&;#8211;) ? – CampbellGolf Oct 06 '12 at 18:35
  • The replacement of "-" with "en dash" worked for me. Also, instead of fetching key from string.xml i passed raw string in tracker.startNewSession() function. Hope it help others. – Wahib Ul Haq Nov 01 '12 at 13:44
0

To Setup

// Add libGoogleAnalytics.jar to your project's /libs directory.

// Add the following permissions to your project's AndroidManifest.xml manifest file:

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

EDIT: In order to use Google Analytics, you must be signed in with a registered Google Account email address and password.

Create a Google Account here. However, just having a Google account does not automatically grant you access to Analytics. First, you must register for Google Analytics, a one-time, simple process.

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130