analytics-plugin-do-not-track
v0.1.5
Published
Disable tracking for opted out visitors plugin for 'analytics' module
Downloads
6,937
Maintainers
Readme
Analytics Do Not Track Plugin
Disable analytics tracking for opted out visitors
This analytics plugin will disable page
, track
, & identify
calls for visitors using Do Not Track.
Usage
Usage with the analytics library.
Install
npm install analytics analytics-plugin-do-not-track
Usage
import Analytics from 'analytics'
import doNotTrack from 'analytics-plugin-do-not-track'
const analytics = Analytics({
app: 'my-app',
plugins: [
doNotTrack(),
]
})
/* if visitor has "do not track" set in browser all tracking will noOp */
// does nothing if DNT on
analytics.page()
// does nothing if DNT on
analytics.track('buttonClick')
// does nothing if DNT on
analytics.identify('bob-lazar')
Standalone usage
A function doNotTrackEnabled
is exposed for usage without the analytics
library.
Install
npm install analytics-plugin-do-not-track
Example
import { doNotTrackEnabled } from 'analytics-plugin-do-not-track'
const isDNT = doNotTrackEnabled()
if (!isDNT) {
// run tracking stuff
}