0
我已經安裝everthing應用程序使用谷歌分析V4,我可以看到「屏幕,活躍用戶,新用戶和頂級設備模型」,但我沒有看到「實時」數據或應用上的活躍用戶。安卓谷歌分析API v4實時
global_tracker.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_trackingId">UA-XXXXXX-X</string>
<integer name="ga_sessionTimeout">300</integer>
<bool name="ga_autoActivityTracking">true</bool>
<string name="ga_logLevel">verbose</string>
<integer name="ga_dispatchPeriod">30</integer>
<bool name="ga_dryRun">false</bool>
<screenName name="com.sounds.MainActivity">MainActivity</screenName>
</resources>
app_tracker.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_trackingId">UA-XXXXXX-X</string>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<string name="ga_appName">soundsapp</string>
<string name="ga_appVersion">3.4</string>
<bool name="ga_debug">true</bool>
<item name="ga_dispatchPeriod" format="integer" type="integer">120</item>
<string name="ga_sampleFrequency">90</string>
<bool name="ga_anonymizeIp">true</bool>
<bool name="ga_dryRun">false</bool>
<string name="ga_sampleFrequency">100.0</string>
<integer name="ga_sessionTimeout">10</integer>
<string name="com.sounds.MainActivity">MainActivity</string>
</resources>
的AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
Trackers.java
public class Trackers extends Application {
private static final String PROPERTY_ID = "UA-XXXXXX-X";
public static int GENERAL_TRACKER = 0;
public enum TrackerName {
APP_TRACKER, // Tracker used only in this app.
GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
}
public HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public Trackers() {
super();
}
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID): (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker): analytics.newTracker(R.xml.ecommerce_tracker);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
}
Activity類
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Tracker t = ((Trackers)this.getApplication()).getTracker(TrackerName.APP_TRACKER);
t.setScreenName("HomePage");
.....
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
GoogleAnalytics.getInstance(this).reportActivityStart(this);
//Get an Analytics tracker to report app starts & uncaught exceptions etc.
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
//Stop the analytics tracking
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
我有同樣的問題。我在「概覽」頁面的第二天看到數據,但沒有「實時」數據。如果我找到什麼,我會通知你 – 2014-10-17 13:43:24