以下のように、テスト プロジェクトで Google アナリティクス v2 ベータ版をセットアップしました。
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 アナリティクス サーバーに送信しようとしましたが、ヒットやアクティビティを見つけることができませんでした。反映に時間がかかる?
Log Cat でこれを見つける
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