Nonchalantly Performs Magic

    analytics-plugin-do-not-track

    0.1.5 • Public • Published

    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
    }

    Install

    npm i analytics-plugin-do-not-track

    DownloadsWeekly Downloads

    1,781

    Version

    0.1.5

    License

    MIT

    Unpacked Size

    17.9 kB

    Total Files

    10

    Last publish

    Collaborators

    • davidwells