1

我已经在一个测试项目中设置了 Google Analytics v2 beta,如下所示

MainActivity.java

public class MainActivity extends Activity {
    Context context;

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

        context = this;

        // Set Context to Google Analytics
        EasyTracker.getInstance().setContext(context);
    }

    @Override
    protected void onStart() {
        super.onStart();
        EasyTracker.getInstance().activityStart(this);

        EasyTracker.getInstance();
        Tracker myTracker = EasyTracker.getTracker();
        myTracker.sendView("harsha");
    }

    @Override
    protected void onStop() {
        super.onStop();
        EasyTracker.getInstance().activityStop(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

分析.xml

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

    <!-- Replace placeholder ID with your tracking ID -->
    <string name="ga_trackingId">UA&#8211;37418075&#8211;1</string>

    <!-- Enable automatic activity tracking -->
    <bool name="ga_autoActivityTracking">true</bool>

    <!-- Enable automatic exception tracking -->
    <bool name="ga_reportUncaughtExceptions">true</bool>
    <bool name="ga_debug">true</bool>
    <!-- The screen names that will appear in your reporting -->
    <string name="com.m7.google_analytics_v2.BaseActivity">Home</string>

</resources>

我一直在尝试将跟踪发送到 Google Analytics Server,但找不到任何点击或任何类型的活动。它需要时间来反映吗?

我在原木猫中找到了这个

01-13 15:16:52.360: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:52.360: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:52.440: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:52.440: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:53.825: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:53.825: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:53.905: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:53.905: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:57.840: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:57.840: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:57.945: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:57.945: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
4

2 回答 2

3

这看起来不太好:

 <string name="ga_trackingId">UA&#8211;37418075&#8211;1</string>

&#8211;(-) 是&ndash; 这是与 ASCII - (-) ( &#45) 不同的字符。我很确定 GA 只希望跟踪 ID 中有 ASCII。

除非在粘贴到堆栈溢出时刚刚插入。

于 2013-01-13T16:33:15.240 回答
1

尝试在管理员下的谷歌分析上创建一个新的配置文件并将其设置为应用程序,它将为您提供一个新的跟踪号。

我有类似的问题,由于某些原因,Google Analytics v2 在我的旧 Google Analytics 项目上不起​​作用,所以我创建了新项目和新配置文件,相同的代码在 24-36 小时后开始报告数据。但是你也可以使用实时数据来检查它是否命中了谷歌分析服务器。

于 2013-01-13T10:43:24.500 回答