User Opt-out

In some cases, it may be necessary to disable the Google Analytics tracking code on a page without having to remove the JavaScript tracking snippet. For example, you might do this if your site's privacy policy includes the ability for a user to opt-out of Google Analytics tracking.

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 true:

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.

This 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.