我一直致力于将Google Analytics v4集成到我的应用程序中。我已经遵循了这一点:https://developers.google.com/analytics/devguides/collection/android/v4/但是,我的分析仪表板并未显示任何数据。
以下是我在应用程序文件中设置的方法:
private static final String PROPERTY_ID = "UA-*******-*";
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 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);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
这是我的全局配置文件:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<!-- the Local LogLevel for Analytics -->
<string name="ga_logLevel">verbose</string>
<!-- how often the dispatcher should fire -->
<integer name="ga_dispatchPeriod">30</integer>
<!-- Treat events as test events and don't send to google -->
<bool name="ga_dryRun">false</bool>
<integer name="ga_sessionTimeout">300</integer>
<!-- The apps Analytics Tracking Id -->
<string name="ga_trackingId">UA-*******-*</string>
<!-- The screen names that will appear in reports -->
<screenName name="com.purpledecks.bottomsup.fragments.frag1">frag1Screen</screenName>
<screenName name="com.purpledecks.bottomsup.fragments.frag2">frag2Screen</screenName>
<screenName name="com.purpledecks.bottomsup.fragments.frag3">frag3Screen</screenName>
</resources>
然后在我的frag1中,我将其设置为按如下方式发送命中:
bottomsUp = (BottomsUpApplication) getActivity().getApplication();
Tracker t = bottomsUp.getTracker(BottomsUpApplication.TrackerName.APP_TRACKER);
t.setScreenName("frag 1");
t.send(new HitBuilders.AppViewBuilder().build());
在我的日志中,我有以下内容:
09-16 11:45:02.552 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: connecting to Analytics service
09-16 11:45:02.572 32411-32411/com.purpledecks.bottomsup V/GAV4﹕ Thread[main,5,main]: service connected, binder: android.os.BinderProxy@43a2e1e0
09-16 11:45:02.572 32411-32411/com.purpledecks.bottomsup V/GAV4﹕ Thread[main,5,main]: bound to service
09-16 11:45:02.572 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: connect: bindService returned true for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
09-16 11:45:02.572 32411-32411/com.purpledecks.bottomsup V/GAV4﹕ Thread[main,5,main]: Connected to service
09-16 11:45:02.572 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: Loaded clientId
09-16 11:45:02.582 32411-32484/com.purpledecks.bottomsup I/GAV4﹕ Thread[GAThread,5,main]: No campaign data found.
09-16 11:45:02.582 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: Initialized GA Thread
09-16 11:45:02.602 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: putHit called
09-16 11:45:02.602 32411-32484/com.purpledecks.bottomsup V/GAV4﹕ Thread[GAThread,5,main]: Sending hit to service PATH: https: PARAMS: ul=en-ie, ht=***********, sr=1080x1920, aid=com.analytics.test, cid=*******************, av=0.0.1, v=1, adid=**************, t=appview, an=Cheers!!, ate=1, tid=UA-********-*, _u=.2nK-AL, cd=frag 1,
同样的问题被问到here但是没有解决方案......任何想法?或者是否有某种方式我应该用项目名称设置属性?
所以它告诉我它正在发送命中,但仪表板上没有任何内容。如果有人能帮助我,或者看看我做错了什么,我会很感激。
答案 0 :(得分:4)
根据要求,我正在添加@DalmTo提供的答案,该答案作为评论提供。
如果您刚刚设置了Google Analytics并且应用程序数据未显示在信息中心上,则通常需要48小时才能激活。因此,如果您没有看到数据允许这段时间过去。