Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 80576a8

Browse files
feat(optin): disable and enable methods
see #109
1 parent ed61991 commit 80576a8

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

docs/opt-out.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ It is also possible to disable tracking from everywhere at any time using the `d
4848
export default {
4949
methods: {
5050
disableTracking () {
51-
this.$ga.disable(true)
52-
// from now on analytics is disabled!
51+
this.$ga.disable()
52+
// from now on analytics is disabled
53+
},
54+
enableTracking () {
55+
this.$ga.enable()
56+
// from now on analytics is enabled
5357
}
5458
}
5559
}

src/lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
time,
2323
screenview,
2424
ecommerce,
25-
disable: noga,
25+
disable: () => noga(true),
26+
enable: () => noga(false),
2627
commands: config.commands
2728
}

src/no-ga.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { getId } from './config'
22

3-
export default () => {
3+
export default (disable = true) => {
44
if (typeof window === 'undefined') {
55
return
66
}
77

88
getId().forEach(id => {
9-
window[`ga-disable-${id}`] = true
9+
window[`ga-disable-${id}`] = disable
1010
})
1111
}

0 commit comments

Comments
 (0)