Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics for Android. Users that receive notifications are counted as active

I am using Google Analytics in my apps and it works correcly. However, if I have, lets say, 100 active users daily, and then I send a notification, I have a peak of 1000 connected users counted as "active".

I don't know if there is an easy way to prevent these users to count as active. Most of them will not open the notification and I don't want them to count as active. I want to count only the users that open the app, not all who received the notification.

I am using "body" field in the notification that I send, and in the app I create a custom notification.

Is it any way to remove these "active" users?

Thank you very much!

like image 650
Javier Delgado Avatar asked Jun 12 '17 14:06

Javier Delgado


People also ask

What is the use of Google Analytics in Android?

With easy-to-use SDKs and reports designed with app developers in mind, Google Analytics for Mobile Apps enables you to: Understand the number of users in your app, their characteristics, and where they come from. Measure what actions your users are taking. Measure in-app payments and revenue.

What is the difference between Google Analytics and Firebase?

Firebase, we see that they have the same data model — one that depicts user interactions as events. That's why both platforms also share the same implementation process — the only difference between Firebase Analytics and Google Analytics in this regard lies in where you first set up your Android and iOS data streams.

How do I turn off Android Analytics?

If you need to deactivate Analytics collection permanently in a version of your app, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES (Boolean) in your app's Info.


1 Answers

Whenever your app receives new Notification, Application OnCreate() method will be invoked.

Not only the Notification, even when you subscribe to system events like ACCESS_WIFI_STATE, ACCESS_NETWORK_STATE, RECEIVE_SMS, RECEIVE_BOOT_COMPLETED.. Application OnCreate() will be invoked.

So inside your Application OnCreate(), don't make any Google Analytics related calls. This will initialize your GA and start the event tracking.

Remove Google Analytics related codes inside your Application OnCreate(), to prevent unwanted event tracking.

Update:

https://developers.google.com/analytics/devguides/collection/android/v4/advanced

getInstance(Context context)
Gets the GoogleAnalytics instance, creating it when necessary.


Multiple way of implementation around this; I recommend you the following way to solve your problem. As document says, prepare the GoogleAnalytics instance, only when it is needed.

Keep the below code inside your Application class, so that your mTracker instance will alive across your application lifecycle.

// Inside Application class
private Tracker mTracker = null;
public synchronized Tracker getDefaultTracker() {
    if (mTracker == null) {
        // Prepare the GoogleAnalytics instance, only when it is needed.
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        mTracker = analytics.newTracker(Config.GA_TRACKING_ID);
        mTracker.enableAutoActivityTracking(true);
        mTracker.enableExceptionReporting(true);
        mTracker.setSessionTimeout(SESSION_TIMEOUT);
    }
    return mTracker;
}

Hope this would help you..

like image 153
Karthi R Avatar answered Oct 03 '22 21:10

Karthi R