android - Google Analytics Automatic Activity Detection - can you exclude a single activity from this? -


automatic activity detection great - except mainactivity bunch of different fragments nav drawer (like google play music or play store). using manual screen hitting track fragments in activity.

therefore, automatic screen hit mainactivity meaningless , pollutes stats. can exclude mainactivity being tracked in manner?

reference: https://developers.google.com/analytics/devguides/collection/android/v4/screens#automatic

just set enableautoactivitytracking(false)to tracker instance obtained in activity.

assuming created getdefaulttracker() method in application class described in the official docs, can create parent class application activities can change auto-tracking behavior on demand:

public abstract class parentactivity extends activity {      tracker mtracker = null;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         gettracker();     }      /* obtains google analytics tracker activity */     tracker gettracker() {         if (mtracker == null) {             analyticsapplication application = (analyticsapplication) getapplication();             mtracker = application.getdefaulttracker();             // enable or disable auto-tracking activity             mtracker.enableautoactivitytracking(shouldautotrack());         }         return mtracker;     }      /* defines whether activity should enable auto-track or not. default true. */     protected boolean shouldautotrack() {         return true;     } } 

your main activity have extend parentactivity , override shouldautotrack method return false:

public class mainactivity extends parentactivity {      /* disable auto-tracking activity */     protected boolean shouldautotrack() {         return false;     }  } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -