public synchronized Tracker getTracker() { if (gaTracker != null) return gaTracker; GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setAppOptOut(isDebuggable); if (isDebuggable) analytics.getLogger().setLogLevel(LogLevel.VERBOSE); gaTracker = analytics.newTracker(ApiObjects.analytics .get("property_id")); gaTracker.enableAdvertisingIdCollection(true); gaTracker.setSessionTimeout(-1); return gaTracker; }
@Override public void onCreate() { super.onCreate(); // Init actions init(); // Check if an update occurred and perform action if needed checkUpdateAction(); // Crashlytics if( BuildConfig.CRASHLYTICS_ACTIVATED ) { Fabric.with(this, new Crashlytics()); Crashlytics.setUserIdentifier(Parameters.getInstance(getApplicationContext()).getString(ParameterKeys.LOCAL_ID)); } // Batch setUpBatchSDK(); // Analytics GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setDryRun(!BuildConfig.ANALYTICS_ACTIVATED); if( BuildConfig.DEBUG_LOG ) { analytics.getLogger().setLogLevel(LogLevel.VERBOSE); } analyticsTracker = analytics.newTracker(R.xml.analytics); // In-app billing setupIab(); }
private Tracker getAnalyticsTracker() { if (mAnalyticsTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.enableAutoActivityReports(this); analytics.getLogger().setLogLevel(LogLevel.VERBOSE); mAnalyticsTracker = analytics.newTracker(mTrackerID); mAnalyticsTracker.enableAutoActivityTracking(true); mAnalyticsTracker.enableExceptionReporting(true); } return mAnalyticsTracker; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE); Tracker t = GoogleAnalytics.getInstance(this).newTracker(GA_TRACKING_CODE); t.setScreenName(this.getClass().getName()); t.send(new HitBuilders.AppViewBuilder().build()); t.setScreenName(null); }
public void initTracker() { mTracker = GoogleAnalytics.getInstance(Model.getInstance().getApplication()).newTracker(R.xml.analytics); if (!Model.getInstance().getConfiguration().isAnalyticsEnabled()) { // When dry run is set, hits will not be dispatched, but will still be logged as // though they were dispatched. GoogleAnalytics.getInstance(Model.getInstance().getApplication()).setDryRun(!Model.getInstance() .getConfiguration().isAnalyticsEnabled()); GoogleAnalytics.getInstance(Model.getInstance().getApplication()).getLogger().setLogLevel(LogLevel.VERBOSE); } }
/** * Gets a new Analytics v4 tracker. * * See: https://developers.google.com/analytics/devguides/collection/android/v4/ * * @param context * @param analyticsTrackingId * @param debugMode If enabled, GA operations will not be sent to Analytics but * are logged. * @return */ public static synchronized Tracker analytics_getTracker(Context context, String analyticsTrackingId, boolean debugMode) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); if(debugMode) { // When dry run is set, hits will not be dispatched, but will still be logged as // though they were dispatched. analytics.setDryRun(true); //Enable logging for GA. analytics.getLogger().setLogLevel(LogLevel.VERBOSE); } return analytics.newTracker(analyticsTrackingId); }