public synchronized Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
/* * GOOGLE ANALYTICS TRACK */ synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker(TRACKER_ID); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
/** * Gets the default {@link Tracker} for this {@link Application}. * * @return tracker */ public synchronized Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.app_tracker); } return mTracker; }
public synchronized Tracker getTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setDryRun(!CityGuideConfig.ANALYTICS); mTracker = analytics.newTracker(R.xml.analytics_app_tracker); } return mTracker; }
private static Logger getLogger() { if (AT == null) { AT = GoogleAnalytics.eD(); } if (AT != null) { return AT.getLogger(); } return null; }
private void startTracker(String id, CallbackContext callbackContext) { if (null != id && id.length() > 0) { tracker = GoogleAnalytics.getInstance(this.cordova.getActivity()).newTracker(id); callbackContext.success("tracker started"); trackerStarted = true; GoogleAnalytics.getInstance(this.cordova.getActivity()).setLocalDispatchPeriod(30); } else { callbackContext.error("tracker id is not valid"); } }
@Provides @Singleton Tracker provideTracker(Application app) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(app); if (BuildConfig.DEBUG) { analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); analytics.setDryRun(true); } return analytics.newTracker(app.getString(R.string.tracking_id)); }
synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(R.xml.app_tracker) : analytics.newTracker(PROPERTY_ID); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
/** * Gets the default {@link Tracker} for this {@link Application}. * * @return tracker */ public synchronized Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker("UA-56060946-4"); mTracker.enableExceptionReporting(true); mTracker.enableAdvertisingIdCollection(false); mTracker.enableAutoActivityTracking(true); } return mTracker; }
public synchronized Tracker getTracker(TrackerName trackerId) { if (!hashMap.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); Tracker t = null; if (trackerId == TrackerName.APP_TRACKER) { t = analytics.newTracker(PROPERTY_ID); } hashMap.put(trackerId, t); } return hashMap.get(trackerId); };
@Provides @Inject public Tracker provideTracker(Context context) { // setup Google analytics GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); analytics.setLocalDispatchPeriod(1800); Tracker tracker = analytics.newTracker(context.getString(R.string.google_analytics_property_id)); tracker.enableExceptionReporting(true); tracker.enableAdvertisingIdCollection(true); tracker.enableAutoActivityTracking(true); return tracker; }
@Override protected void onStop() { // TODO Auto-generated method stub // Stop the analytics tracking GoogleAnalytics.getInstance(this).reportActivityStop(this); super.onStop(); }
@Override protected void onStart() { // TODO Auto-generated method stub // Get an Analytics tracker to report app starts & uncaught exceptions etc. GoogleAnalytics.getInstance(this).reportActivityStart(this); super.onStart(); }
@Override protected void onStop() { super.onStop(); // Stop the analytics tracking GoogleAnalytics.getInstance(this).reportActivityStop(this); }
@Override protected void onStart() { super.onStart(); // Get an Analytics tracker to report app starts & uncaught exceptions // etc. GoogleAnalytics.getInstance(this).reportActivityStart(this); }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.equals(customApiUrlPref) && newValue instanceof String) { String apiUrl = (String) newValue; if (!TextUtils.isEmpty(apiUrl)) { // User entered a custom API Url, so set the region info to null Application.get().setCurrentRegion(null); if (BuildConfig.DEBUG) { Log.d(TAG, "User entered new API URL, set region to null."); } } else { // User cleared the API URL preference value, so re-initialize regions if (BuildConfig.DEBUG) { Log.d(TAG, "User entered blank API URL, re-initializing regions..."); } NavHelp.goHome(this); } } else if (preference.equals(analyticsPref) && newValue instanceof Boolean) { Boolean isAnalyticsActive = (Boolean) newValue; // Report if the analytics turns off, just before shared preference changed if (!isAnalyticsActive) { ObaAnalytics.reportEventWithCategory( ObaAnalytics.ObaEventCategory.APP_SETTINGS.toString(), getString(R.string.analytics_action_edit_general), getString(R.string.analytics_label_analytic_preference) + (isAnalyticsActive ? "YES" : "NO")); GoogleAnalytics.getInstance(getBaseContext()).dispatchLocalHits(); } } return true; }
@Override protected void onStart() { super.onStart(); GoogleAnalytics.getInstance(act).reportActivityStart(act); // GA t = ((MyAnalytics) act.getApplication()).getTracker(TrackerName.APP_TRACKER); GA_Util.sendScreen(t, tag); }
@Provides @Singleton Analytics provideAnalytics() { if (BuildConfig.DEBUG) { return new Analytics() { @Override public void send(Map<String, String> params) { Timber.tag("Analytics").d(String.valueOf(params)); } }; } GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(app); Tracker tracker = googleAnalytics.newTracker(BuildConfig.ANALYTICS_KEY); tracker.setSessionTimeout(300); // ms? s? better be s. return new Analytics.GoogleAnalytics(tracker); }
private void debugMode(CallbackContext callbackContext) { GoogleAnalytics.getInstance(this.cordova.getActivity()) .getLogger() .setLogLevel(LogLevel.VERBOSE); this.debugModeEnabled = true; callbackContext.success("debugMode enabled"); }
@Override protected void onStop() { if (mLastCameraPosition != null) { saveMapLocation(mLastCameraPosition); } GoogleAnalytics.getInstance(this).reportActivityStop(this); super.onStop(); }
@Provides @Singleton public Analytics provideAnalytics() { // Only send analytics to Google Analytics with versions of the app that are NOT debuggable // (such as BETA or RELEASE) if (BuildConfig.DEBUG) { return new Analytics() { @Override public void send(Map<String, String> params) { Log.d(TAG, String.valueOf(params)); } }; } GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(app); Tracker tracker = googleAnalytics.newTracker(BuildConfig.ANALYTICS_KEY); // tracker.setSessionTimeout(300); // default is 30 seconds return new Analytics.GoogleAnalytics(tracker); }
private synchronized Tracker getDefaultTracker() { try { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(SpilConfig.getInstance(this).getGoogleAnalyticsId()); mTracker.enableExceptionReporting(true); mTracker.enableAutoActivityTracking(true); return mTracker; } } catch (Exception | NoClassDefFoundError e) { LoggingUtil.v( "Google Analytics couldn't be initialised. " + "Please make sure you have the necessary dependencies and you included the 'googleAnalyticsId' key-value in your 'defaultGameConfig.json' file"); } return null; }
@Override public void onCreate() { super.onCreate(); // At this point the Application object was created by the OS. Save instance for singleton _instance = this; // Initialize the database _database = createDatabase(); Resources res = getResources(); // Get the default number of bars to show in the anomaly chart _chartTotalBars = res.getInteger(R.integer.chart_total_bars); // Whether or not we should upload the android logs to the server _uploadLog = res.getBoolean(R.bool.upload_logs); // The number of records for which the model is still learning _learningThreshold = res.getInteger(R.integer.learning_threshold); // Maximum number of days to sync. _numberOfDaysToSync = res.getInteger(R.integer.number_of_days_to_sync); // Configure Anomaly bar settings _yellowBarFloor = res.getFraction(R.fraction.yellow_bar_floor, 1, 1); _redBarFloor = res.getFraction(R.fraction.red_bar_floor, 1, 1); // Default aggregation _aggregation = AggregationType.valueOf(res.getString(R.string.aggregation_type)); // Application name _applicationName = res.getString(R.string.application_name); // Get this device ID _deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); // Initialize Google Analytics try { String trackingId = res.getString(R.string.ga_trackingId); if (trackingId != null && !trackingId.isEmpty()) { _tracker = GoogleAnalytics.getInstance(this).newTracker(trackingId); _tracker.enableAutoActivityTracking(true); _tracker.enableExceptionReporting(true); } else { Log.w(TAG, "Failed to initialize Google Analytics. Invalid value for 'ga_trackingId'"); } } catch (Resources.NotFoundException e) { Log.w(TAG, "Failed to initialize Google Analytics. Missing value for 'ga_trackingId'"); } // Start background data synchronization service if (res.getBoolean(R.bool.start_services)) { startBackgroundServices(); } }
public void trackScreenView(String screenName) { Tracker t = getGoogleAnalyticsTracker(); // Set screen name. t.setScreenName(screenName); // Send a screen view. t.send(new HitBuilders.ScreenViewBuilder().build()); GoogleAnalytics.getInstance(this).dispatchLocalHits(); }
/** * Send screen name tracking * * @param screenName */ public void sendScreenTracking(String screenName) { // Get tracker. Tracker t = GoogleAnalytics.getInstance(this).newTracker(PROPERTY_ID); // Set screen name. // Where path is a String representing the screen name. t.setScreenName(screenName); // Send a screen view. t.send(new HitBuilders.AppViewBuilder().build()); }
public void sendEventTracking(int categoryId, int actionId, String label) { // Get tracker. Tracker t = GoogleAnalytics.getInstance(this).newTracker(PROPERTY_ID); // Build and send an Event. t.send( new HitBuilders.EventBuilder() .setCategory(getString(categoryId)) .setAction(getString(actionId)) .setLabel(label) .build()); }
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }
@Override public Integration<?> create(ValueMap settings, Analytics analytics) { Logger logger = analytics.logger(GOOGLE_ANALYTICS_KEY); if (!hasPermission( analytics.getApplication(), Manifest.permission.ACCESS_NETWORK_STATE)) { logger.debug("ACCESS_NETWORK_STATE is required for Google Analytics."); return null; } String mobileTrackingId = settings.getString("mobileTrackingId"); if (isNullOrEmpty(mobileTrackingId)) { logger.debug("mobileTrackingId is required for Google Analytics."); return null; } Context context = analytics.getApplication(); com.google.android.gms.analytics.GoogleAnalytics ga = com.google.android.gms.analytics.GoogleAnalytics.getInstance(context); GoogleAnalytics googleAnalytics = new DefaultGoogleAnalytics(ga); return new GoogleAnalyticsIntegration(context, googleAnalytics, settings, logger); }
@Override protected void onStart() { super.onStart(); Boolean analyticsViewed = mSharedPref.getAnalyticsViewed(); if (!analyticsViewed) { // Display Google Analytics Message Log.v(TAG, "VIEWED: " + String.valueOf(analyticsViewed)); // Request Permissions mMessageHelper.enableFeatureDialog( mContext, getString(R.string.dialog_ga_title), getString(R.string.dialog_ga_message), new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); // Set boolean opt-in mSharedPref.setAnalyticsOptOut(false); mSharedPref.setAnalyticsViewed(true); GoogleAnalytics.getInstance(mContext).setAppOptOut(false); dialog.dismiss(); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); // Set boolean opt-out mSharedPref.setAnalyticsOptOut(true); mSharedPref.setAnalyticsViewed(true); GoogleAnalytics.getInstance(mContext).setAppOptOut(true); dialog.dismiss(); } }); } GoogleAnalytics.getInstance(this).reportActivityStart(this); } // onStart
@Override protected void onStop() { super.onStop(); GoogleAnalytics.getInstance(act).reportActivityStop(act); }