适用于Android的Google Analytics(分析).收到通知的用户被视为活动用户 [英] Google Analytics for Android. Users that receive notifications are counted as active

查看:36
本文介绍了适用于Android的Google Analytics(分析).收到通知的用户被视为活动用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了Google Analytics(分析),并且可以正常运行.但是,如果我假设每天有100个活跃用户,然后发送通知,则高峰时有1000个已连接用户被视为活跃".

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?

非常感谢!

推荐答案

只要您的应用程序收到新的通知,就会调用应用程序 OnCreate()方法.

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

不仅通知,即使您订阅了诸如ACCESS_WIFI_STATE,ACCESS_NETWORK_STATE,RECEIVE_SMS,RECEIVE_BOOT_COMPLETED的系统事件,也会被调用.应用程序OnCreate()会被调用.

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.

因此,在您的应用程序 OnCreate()中,请勿进行与Google Analytics(分析)相关的任何调用.这将初始化您的GA,并开始事件跟踪.

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

删除应用程序 OnCreate()中与Google Analytics(分析)相关的代码,以防止不必要的事件跟踪.

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

更新:

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

getInstance(上下文上下文)
获取 GoogleAnalytics 实例,并在必要时创建它.

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


围绕此的多种实现方式;我建议您通过以下方式解决您的问题.如文件所述,仅在需要时准备GoogleAnalytics实例.


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.

将下面的代码保留在Application类中,以便您的 mTracker 实例在整个应用程序生命周期中都有效.

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;
}

希望这对您有帮助.

这篇关于适用于Android的Google Analytics(分析).收到通知的用户被视为活动用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆