This could be the case if your site needs to respect stricter privacy laws like the ones imposed through GDPR in the EU where your users need to have the option to opt-out of Google Analytics tracking.
Tracking Opt-out For Your Site
To opt-out of tracking for your site, you need to set the following window property to
window['ga-disable-UA-XXXXX-Y'] = true;
The value of
UA-XXXXX-Y corresponds to the property ID where you wish to disable the tracking.
Google Analytics checks if the window property is set to
true in which case it will no longer set a cookie and send data back to the servers. This has to be set before any
ga() calls and on each page you wish to disable Google Analytics tracking.
Tracking Opt-out For All Sites
If you wish to opt-out of tracking on all the sites where Google Analytics is installed on (sites you don't have access to the source code), you can install Google Analytics opt-out browser add-on.
But There's A Catch
Although you've disabled tracking with persistent cookies users can still be tracked through an approach called fingerprinting. Fingerprints can be used to fully or partially identify individual users or devices even when they're attempting to avoid tracking and this raises a major concern for privacy.
What Can You Do?
You can start using alternatives to Google Analytics that provide useful measurements while remaining respectful in regards to the personal data of the users.
123Metrics does just that by being a privacy-centered service which offers a way of measuring your website efficiency and performance with non-intrusive metrics.
You will no longer have to deal with the hassle of GDPR when it comes to your website analytics because 123Metrics is built from the ground up with a focus on privacy.