Java Code Examples for com.google.android.gms.analytics.Tracker#enableAdvertisingIdCollection()

The following examples show how to use com.google.android.gms.analytics.Tracker#enableAdvertisingIdCollection() . 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: 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 2
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 3
Source File: NoyzeApp.java    From Noyze with Apache License 2.0 5 votes vote down vote up
synchronized Tracker getTracker(TrackerName trackerId) {
    if (!mTrackers.containsKey(trackerId)) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker("UA-41252760-2")
                : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
                : analytics.newTracker(R.xml.global_tracker);
        t.enableAdvertisingIdCollection(false);
        t.setAnonymizeIp(true);
        t.setUseSecure(true);
        mTrackers.put(trackerId, t);

    }
    return mTrackers.get(trackerId);
}
 
Example 4
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 5
Source File: NoyzeApp.java    From Noyze with Apache License 2.0 5 votes vote down vote up
synchronized Tracker getTracker(TrackerName trackerId) {
    if (!mTrackers.containsKey(trackerId)) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker("UA-41252760-2")
                : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
                : analytics.newTracker(R.xml.global_tracker);
        t.enableAdvertisingIdCollection(false);
        t.setAnonymizeIp(true);
        t.setUseSecure(true);
        mTrackers.put(trackerId, t);

    }
    return mTrackers.get(trackerId);
}
 
Example 6
Source File: OnesearchApp.java    From Onesearch with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // Enabling Advertising Features in Google Analytics allows you to take advantage of
    // Remarketing, Demographics & Interests reports, and more.
    Tracker t = getTracker(TrackerName.APP_TRACKER);
    t.enableAdvertisingIdCollection(true);

    if(BuildConfig.DEBUG) {
        GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        GoogleAnalytics.getInstance(this).setDryRun(true);
    }
}