我已经在一个测试项目中设置了 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–37418075–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