Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feat(optin): disable and enable methods
Browse files Browse the repository at this point in the history
see #109
  • Loading branch information
MatteoGabriele committed May 19, 2018
1 parent ed61991 commit 80576a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions docs/opt-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
time,
screenview,
ecommerce,
disable: noga,
disable: () => noga(true),
enable: () => noga(false),
commands: config.commands
}
4 changes: 2 additions & 2 deletions src/no-ga.js
Original file line number Diff line number Diff line change
@@ -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
})
}

0 comments on commit 80576a8

Please sign in to comment.