Java Code Examples for com.google.android.gms.analytics.GoogleAnalytics#newTracker()

The following examples show how to use com.google.android.gms.analytics.GoogleAnalytics#newTracker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PatrolApp.java    From patrol-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
    try {
        if (mTracker == null) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
            mTracker = analytics.newTracker("UA-44978148-14");
        }
    } catch (Exception e){
        e.printStackTrace();
    }
    return mTracker;
}
 
Example 2
Source File: ClimbTrackerApplication.java    From climb-tracker with Apache License 2.0 5 votes vote down vote up
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    return mTracker;
}
 
Example 3
Source File: AppModule.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Singleton
@Provides
public Tracker provideGoogleAnalyticsTracker(Context context) {
    GoogleAnalytics ga = GoogleAnalytics.getInstance(context);
    Tracker tracker = ga.newTracker(BuildConfig.GA_TRACKING_ID);
    tracker.enableAdvertisingIdCollection(true);
    tracker.enableExceptionReporting(true);
    return tracker;
}
 
Example 4
Source File: GoogleAnalyticsHelper.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static void pushAnalyticsData(Context context, QBUser user, String action) {
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
    Tracker tracker = analytics.newTracker(context.getString(R.string.google_analytics_tracking_id));

    // You only need to set User ID on a tracker once. By setting it on the tracker, the ID will be
    // sent with all subsequent hits.
    tracker.set("&uid", String.valueOf(user.getId()));
    // This hit will be sent with the User ID value and be visible in User-ID-enabled views (profiles).
    tracker.send(new HitBuilders.EventBuilder().setCategory("UX").setAction(action).build());
}
 
Example 5
Source File: AppModule.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Singleton
@Provides
public Tracker provideGoogleAnalyticsTracker(Context context) {
    GoogleAnalytics ga = GoogleAnalytics.getInstance(context);
    Tracker tracker = ga.newTracker(BuildConfig.GA_TRACKING_ID);
    tracker.enableAdvertisingIdCollection(true);
    tracker.enableExceptionReporting(true);
    return tracker;
}
 
Example 6
Source File: Analytics.java    From openshop.io-android with MIT License 5 votes vote down vote up
/**
 * Prepare Google analytics trackers and Facebook events logger.
 * Send UTM campaign if exist.
 *
 * @param shop    shop with app specific Google Ua or null, if global tracker is enough.
 * @param context application context.
 */
public static synchronized void prepareTrackersAndFbLogger(Shop shop, Context context) {
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
    // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG

    if (shop == null) {
        deleteAppTrackers();
    } else {
        if (!mTrackers.containsKey(TRACKER_APP) && analytics != null) {
            if (shop.getGoogleUa() != null && !shop.getGoogleUa().isEmpty()) {
                Timber.d("Set new app tracker with id: %s", shop.getGoogleUa());
                // App tracker determined by shop
                Tracker appTracker = analytics.newTracker(shop.getGoogleUa());
                appTracker.enableAutoActivityTracking(true);
                appTracker.enableExceptionReporting(false);
                appTracker.enableAdvertisingIdCollection(true);
                mTrackers.put(TRACKER_APP, appTracker);
            } else {
                Timber.e(new RuntimeException(), "Creating GA app tracker with empty Google UA");
            }
        } else {
            Timber.e("Trackers for this app already exist.");
        }
    }

    // Add global tracker only one time.
    if (!mTrackers.containsKey(TRACKER_GLOBAL) && analytics != null) {
        Timber.d("Set new global tracker.");
        // Global app tracker
        Tracker appTrackerGlobal = analytics.newTracker(R.xml.global_tracker);
        appTrackerGlobal.enableAutoActivityTracking(true);
        appTrackerGlobal.enableExceptionReporting(true);
        appTrackerGlobal.enableAdvertisingIdCollection(true);
        mTrackers.put(TRACKER_GLOBAL, appTrackerGlobal);
        // Send camping info only once time.
        sendCampaignInfo();
    }

    facebookLogger = AppEventsLogger.newLogger(MyApplication.getInstance());
}
 
Example 7
Source File: MainActivity.java    From Smartlab with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
	Tracker t = analytics.newTracker("UA-43986081-2");	
	t.send(new HitBuilders.AppViewBuilder().build());
}
 
Example 8
Source File: AnalyticsUtil.java    From IndiaSatelliteWeather with GNU General Public License v2.0 5 votes vote down vote up
public synchronized Tracker getTracker() {
    if (gaTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
        gaTracker = analytics.newTracker(GLOBAL_PROPERTY_ID);
    }
    return gaTracker;
}
 
Example 9
Source File: Stats.java    From materialup with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
synchronized public Tracker getDefaultTracker(Context ctx) {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(ctx.getApplicationContext());
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker("UA-68232106-2");
    }
    return mTracker;
}
 
Example 10
Source File: AnalyticsHelper.java    From friendlyping with Apache License 2.0 5 votes vote down vote up
/**
 * Get the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
public static synchronized Tracker getDefaultTracker(Context context) {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics
                .getInstance(context.getApplicationContext());
        analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    return mTracker;
}
 
Example 11
Source File: NotificationSender.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
synchronized Tracker getTracker(TrackerName trackerId) {
  if (!mTrackers.containsKey(trackerId)) {

    GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext);
    Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PressureNETConfiguration.GA_TOKEN)
        : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
            : analytics.newTracker(R.xml.global_tracker);
    mTrackers.put(trackerId, t);

  }
  return mTrackers.get(trackerId);
}
 
Example 12
Source File: MiracastApplication.java    From miracast-widget with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public 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.global_tracker);
    }
    return mTracker;
}
 
Example 13
Source File: OnesearchApp.java    From Onesearch with MIT License 5 votes vote down vote up
public synchronized Tracker getTracker(TrackerName trackerId) {
    if (!mTrackers.containsKey(trackerId)) {

        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID)
                : analytics.newTracker(R.xml.global_tracker);
        mTrackers.put(trackerId, t);

    }
    return mTrackers.get(trackerId);
}
 
Example 14
Source File: BaseApplication.java    From example with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
synchronized public 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.global_tracker);
  }
  return mTracker;
}
 
Example 15
Source File: App.java    From CoolApk-Console with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public 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.global_tracker);
    }
    return mTracker;
}
 
Example 16
Source File: AnalyticsApplication.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 5 votes vote down vote up
public void event(String s) {
    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.global_tracker);
    }
    mTracker.send(new HitBuilders.EventBuilder()
            .setCategory("Action")
            .setAction(s)
            .build());
}
 
Example 17
Source File: AnalyticsApplication.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 5 votes vote down vote up
synchronized public void track(String s) {
    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.global_tracker);
    }
    mTracker.setScreenName(s);
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
 
Example 18
Source File: TapchatAnalytics.java    From tapchat-android with Apache License 2.0 4 votes vote down vote up
public TapchatAnalytics(Context context) {
    GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(context);
    mTracker = googleAnalytics.newTracker(TRACKING_ID);
}
 
Example 19
Source File: SilentFragment.java    From KUAS-AP-Material with MIT License 4 votes vote down vote up
public void initGA(String screenName, Activity activity) {
	GoogleAnalytics analytics = GoogleAnalytics.getInstance(activity);
	mTracker = analytics.newTracker(Constant.GA_ID);
	mTracker.setScreenName(screenName);
	mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
 
Example 20
Source File: QuizApp.java    From android-quiz-php with BSD 2-Clause "Simplified" License 2 votes vote down vote up
synchronized Tracker getTracker() {

        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

        return analytics.newTracker(R.xml.ga_tracker);
    }