diff --git a/docs/opt-out.md b/docs/opt-out.md index 0ebe3e8..52ab970 100644 --- a/docs/opt-out.md +++ b/docs/opt-out.md @@ -48,8 +48,12 @@ It is also possible to disable tracking from everywhere at any time using the `d export default { methods: { disableTracking () { - this.$ga.disable(true) - // from now on analytics is disabled! + this.$ga.disable() + // from now on analytics is disabled + }, + enableTracking () { + this.$ga.enable() + // from now on analytics is enabled } } } diff --git a/src/lib/index.js b/src/lib/index.js index 19d968b..d0af51d 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -22,6 +22,7 @@ export default { time, screenview, ecommerce, - disable: noga, + disable: () => noga(true), + enable: () => noga(false), commands: config.commands } diff --git a/src/no-ga.js b/src/no-ga.js index c9aed7a..8edef7b 100644 --- a/src/no-ga.js +++ b/src/no-ga.js @@ -1,11 +1,11 @@ import { getId } from './config' -export default () => { +export default (disable = true) => { if (typeof window === 'undefined') { return } getId().forEach(id => { - window[`ga-disable-${id}`] = true + window[`ga-disable-${id}`] = disable }) } \ No newline at end of file