简体   繁体   English

为什么屏幕视图两次发送到Android上的Google Analytics(分析)

[英]Why a screen view is sent twice to Google Analytics on android

I am using Google Analytics for Android v4. 我正在使用适用于Android v4的Google Analytics(分析)。 I have attached code, whats happening is each time i dispatch the local hit , it is sent twice and appears twice on Dashboard once for Screen name and once for Activity package name, not sure whats wrong with code. 我已经附上了代码,发生的事情是每次我发送本地匹配时,它将发送两次,并在仪表板上出现两次,一次是“屏幕名称”,一次是“活动”程序包名称,不知道代码有什么问题。

The global_tracker.xml file global_tracker.xml文件

<?xml version="1.0" encoding="utf-8"?>
    <resources
        xmlns:tools="http://schemas.android.com/tools"
        tools:ignore="TypographyDashes">

        <integer name="ga_sessionTimeout">300</integer>
        <bool name="ga_autoActivityTracking">true</bool>
        <bool name="ga_anonymizeIp">true</bool>
        <string name="ga_trackingId">UA-XXXXXXX-2</string>
        <int name="ga_dispatchPeriod">-10</int>
    </resources>

The activity code 活动代码

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

        webFunction = new WebFunctions();
        dbFunction = new DatabaseFuncitons();
        progressDialog = new ProgressDialog(ActivityLogin.this);

        editTextUsername = (EditText) findViewById(R.id.editTextUsername);
        editTextPassword = (EditText) findViewById(R.id.editTextPassword);

        Tracker t = GoogleAnalytics.getInstance(this).newTracker(R.xml.global_tracker);
        t.setScreenName("/Login");

        t.send(new HitBuilders.ScreenViewBuilder().build());

        GoogleAnalytics.getInstance(getBaseContext()).dispatchLocalHits();

        GoogleAnalytics.getInstance(this).getLogger()
                .setLogLevel(Logger.LogLevel.VERBOSE);
    }

The code is doing exactly what you told it to do. 该代码完全按照您的指示执行。

Here, you send out a hit: 在这里,您发出了匹配:

t.send(new HitBuilders.ScreenViewBuilder().build());

then on the next line, you manually dispatch local hits: 然后在下一行中,您手动调度本地匹配:

GoogleAnalytics.getInstance(getBaseContext()).dispatchLocalHits();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM