Google Analytics Demographics for Android App

I used the Google Analytics Demographics for an Android application using the Google Play services library. I updated my android code using enableAdvertisingIdCollection (). its working tone with screens and data. But does his demographic information not work? Suggest how to handle demographics.

thank you.

Code: Application Code:

...

synchronized Tracker getTracker( TrackerName trackerId, String appKey) { Log.d("Application", "In Application class getTracker PID" + appKey); if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setDryRun(false); analytics.getLogger().setLogLevel(Logger.LogLevel.INFO); Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(appKey) : analytics .newTracker(R.xml.app_tracker); if (t != null) { t.enableAdvertisingIdCollection(true); } mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); } 

...

code on oncreate ()

...

  try { GoogleAnalytics.getInstance(getActivity()).reportActivityStart(getActivity()); Tracker t = ((AppApplication) getActivity().getApplication()).getTracker(TrackerName.APP_TRACKER, Appkey); t.setScreenName("Home Screen"); // t.setSampleRate(sampleRate); t.enableAdvertisingIdCollection(true); t.send(new HitBuilders.AppViewBuilder().build()); } catch (Exception ex) { CustomLogger.showLog("GAcode", ex.getMessage()); } 
+8
android google-analytics google-analytics-api universal-analytics
source share
2 answers

I carefully studied the Google documentation, and most of the stackoverflow and Facebook links did not find any help or code customization that could allow demographics in Android mobile apps for the recent google sdk. But still I found my own demographics, sending events through a tracker with details about people.

So, I came to the conclusion that Google Analytics Demographics works great with web applications, but does not yet support Android applications.

0
source share

Just to help others, Google support is a lot unclear in this piece of code:

Enable advertising features

// Get tracker.

 Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker( TrackerName.APP_TRACKER); 

// Enable advertising features.

 t.enableAdvertisingIdCollection(true); 



A tracker contains a tracker initialized in your Application class, and the tracking function is a function in which you must create a list of trackers and get them by name. If you use only one tracker, you can do:

  public static Tracker tracker; @Override public void onCreate() { super.onCreate(); startGoogleAnalytics(); } public void startGoogleAnalytics() { 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 Tracker getTracker() { if (tracker == null) { startGoogleAnalytics(); } return tracker; } 

Then you can do the following:

  Tracker t = ((YouApplicationClassName)getApplication()).getTracker(); t.enableAdvertisingIdCollection(true); 
+2
source share

All Articles