Opt-out of tracking for your site
The analytics.js library includes a window property that, when set to
true, disables analytics.js from sending data to Google Analytics. When Google Analytics attempts to set a cookie or send data back to the Google Analytics servers, it will check whether this property is set to
true. If it is, no action will be taken.
To disable tracking, set the following
window property to
window['ga-disable-UA-XXXXX-Y'] = true;
Where the value
UA-XXXXX-Y corresponds to the property ID on which you would like to disable tracking.
window property must be set before any calls to the
ga() command queue are made, and it must be set on each page for which you want to disable Google Analytics tracking. If the property is not set or set to
false then tracking will work as usual.
Opt-out of tracking on all sites
To opt-out of Google Analytics tracking for all sites, even sites whose source code you do not control, you can install the Google Analytics opt-out browser add-on.