Google Analytics Demographics For Android App
Solution 1:
Just for helping others, google support is a lot unclear about this piece of code:
Enabling Advertising Features
// Get tracker.
Trackert= ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Enable Advertising Features.
t.enableAdvertisingIdCollection(true);
The tracker there is the tracker initialized in your Application class, and get tracker is a function where you should create a List of trackers and get them by name. If you are using just one tracker, you can do:
publicstaticTracker tracker;
@OverridepublicvoidonCreate() {
super.onCreate();
startGoogleAnalytics();
}
publicvoidstartGoogleAnalytics() {
analytics = GoogleAnalytics.getInstance(this);
analytics.setLocalDispatchPeriod(1800);
tracker = analytics.newTracker(R.xml.global_tracker); // here you can add just your id value too
tracker.enableExceptionReporting(true);
tracker.enableAdvertisingIdCollection(true);
tracker.enableAutoActivityTracking(true);
}
public synchronized TrackergetTracker() {
if (tracker == null) {
startGoogleAnalytics();
}
return tracker;
}
Then on your activity you can do:
Trackert= ((YouApplicationClassName)getApplication()).getTracker();
t.enableAdvertisingIdCollection(true);
Solution 2:
I looked at google documentation thoroughly, and as well as most of the stackoverflow and Facebook links, I didn't found any help or code tweak that could enable demographics in android mobile apps for recent google sdk. But still i found custom demographics by sending events through tracker with details about people.
So ,I concluded that Google Analytics Demographics works perfectly with web apps but yet it did not support android apps.
Post a Comment for "Google Analytics Demographics For Android App"