I have set up google analytics in my NuxtJs app, I also have cookies that save the preferences of the users. when the user rejects the cookies, I set a cookie where Cookie.set('disableAnalytics', true);
and also in my nuxt.config.js
file, I have where
require('dotenv').config()
import Cookie from 'js-cookie';
export default {
googleAnalytics: {
id: process.env.GOOGLE_ANALYTICS_ID,
disableScriptLoader: Cookie.get("disableAnalytics") || false
}
}
I EXPECT that it somehow disables the script loader, and cause google analytics to not track the user.
BUT THIS IS NOT THE CASE, when I check the analytics console while visiting the site, Google analytics is still tracking.
Please, How can I solve the problem, and stop google analytics from tracking when the disableAnalytics
cookie is set to true
?