Open lapo-luchini opened 5 years ago
I need to understand what you are encountering a little better. The disableAnalytics()
config method sets a variable during configuration, that is all, so it is not generating an error on its own.
The reason this requires an account is because this is a feature of GA and something we are exposing during the script injection on the page. This is the code performing this:
if (disableAnalytics === true) {
accounts.forEach(function (trackerObj) {
that._log('info', 'Analytics disabled: ' + trackerObj.tracker);
$window['ga-disable-' + trackerObj.tracker] = true;
});
}
As you can tell this requires at least one account to exist. This entire library is premised on at least 1 account being defined for operation and a warning is issued during tracker registration if the list is undefined or empty.
Your particular use case sounds like what you expected was a way to disable the Analytics service and not just the GA behaviors.
Hi, for the sake of avoiding an
if
around everyAnalytics.trackEvent
line we have in our code, I'd like to have a way to disable this module when a UA account is not defined (that's an option that our users will have to use or not).Unfortunately
disableAnalytics
requires an account or gives a stack trace exception, so I worked it around like this:This works ok (and any page change and event tracking generate no errors), but is there a recommended way to achieve this?