Directory

← Back

AnonymizedGoogleAnalyticsTracker

Extends the GoogleAnalyticsTracker Vaadin Add-On by additional features for privacy protection. In some countries these features are required for legal usage of GoogleAnalytics.

Author

Contributors

Rating

Extends the GoogleAnalyticsTracker Vaadin Add-On by additional features for privacy protection. In some countries these features are required for legal usage of GoogleAnalytics.

(1) IP Anonymization Enables the "AnonymizeIP" parameter in the GA tracking. Can be disabled by setAnonymizeIp(false). If AnonymizeIP is enabled Google doesn't store the complete IP of the user. Check the GoogleAnalytics API documentation for more information about that parameter (see link section). This feature is only available when using the universal tracking mode.

(2) Opt-out support Provides an opt-out option by calling the method addOptOutCookie(). It sets a cookie which disables tracking for the user.

Sample code

// Create a tracker for vaadin.com domain. The Anonymized extension supports the same constructors as the original add-on.
AnonymizedGoogleAnalyticsTracker tracker = new AnonymizedGoogleAnalyticsTracker ("UA-658457-8", "vaadin.com");

// Attach this analytics component to a UI to enable tracking
tracker.extend(UI.getCurrent());

// Track the page view
tracker.trackPageview("/samplecode/googleanalytics");

// Or add the tracker as ViewChangeListener to the navigator to automatically track every view change
UI.getCurrent().getNavigator().addViewChangeListener(tracker);

// Set opt-out cookie to the user's browser to disable tracking
tracker.addOptOutCookie();

// Check if opt-out cookie exists
tracker.isOptOut();

// If you like to switch off the IP anonymization (for whatever reason)
tracker.setAnonymizeIp(false);

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

no functional changes at all; only removed unnecessary auto-generated WidgetSet entry from pom.xml resp. MANIFEST.MF as it caused GWT compiler errors

Released
2016-02-06
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.1+
Browser
Browser Independent
Online