1

I am using Google Analytics in my android app. But I don't see any data in my analytics account.

Please suggest me how to use it.

I am using below method to invoke/share analytics.

AppAnalytics.shareAnalytics("Error","ButtonClick","Error occured on Bt1 click.");

AppAnalytics.java:

public class AppAnalytics  extends Application {

    private Context context;

    public AppAnalytics(Context context) {
        super();
        this.context = context;
    }

    synchronized Tracker getTracker() {

        GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
        analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        Tracker t = analytics.newTracker(R.string.analytics_id);
        t.enableAdvertisingIdCollection(true);
        return t;
    }

    public void shareAnalytics(String category, String action, String label) {
        try {
            Tracker t = getTracker();
            t.send(new HitBuilders.EventBuilder().setCategory(category)
                    .setAction(action).setLabel(label).build());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Sufian
  • 6,405
  • 16
  • 66
  • 120
Anand Yerrapati
  • 115
  • 2
  • 11
  • Does it throw any exception? See your log as well. Also, please be sure to initialise tracker like `myTracker = GoogleAnalytics.getInstance(context).newTracker(myTrackingId);` – Sufian Oct 06 '15 at 14:14
  • Sufian, thanks for your reply. I dont see any error. And as you see in the above code, newTracker() method is invoked. – Anand Yerrapati Oct 07 '15 at 07:16
  • **1.** Make sure that `R.string.analytics_id` refers the correct tracking id of the Analytics. **2.** check that you are not applying any sort of filters when viewing the Analytics. **3.** see that you are connected to working internet connection. **4.** have you made the changes in the manifest? Please post it as well. – Sufian Oct 07 '15 at 08:15
  • tracking id is correct. I have checked the ayalytics site. I dont have any filter and it is set to default view only. Now I have below permissions as per the documentations. Do I need anything else in the manifest file? – Anand Yerrapati Oct 07 '15 at 09:03
  • 1
    I think you are missing something. See [this question](http://stackoverflow.com/questions/30154057/analyticsservice-not-registered-in-the-app-manifest-error). Does it help? – Sufian Oct 07 '15 at 09:17
  • I will try this. Thanks Sufian. – Anand Yerrapati Oct 07 '15 at 11:24
  • Yes follow the answer and comment here whatever the outcome is. – Sufian Oct 07 '15 at 11:38
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/91696/discussion-between-sufian-and-anand-y). – Sufian Oct 08 '15 at 06:00
  • I can see the sessions in my analytics now, the above link helped me. Thanks for your help Sufian. – Anand Yerrapati Oct 12 '15 at 12:23

0 Answers0