Do Not Track

Using the 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.

How to use

First install the packages from npm.

npm install analytics
npm install analytics-plugin-do-not-track

Then initialize analytics with the analytics-plugin-do-not-track plugin.

import Analytics from 'analytics'
import doNotTrack from 'analytics-plugin-do-not-track'

const analytics = Analytics({
  app: 'my-app',
  plugins: [

/* if visitor has "do not track" set in browser all tracking will noOp */

// does nothing if DNT on

// does nothing if DNT on

// does nothing if DNT on

Standalone usage

A function doNotTrackEnabled is exposed for usage without the analytics library.


npm install analytics-plugin-do-not-track


import { doNotTrackEnabled } from 'analytics-plugin-do-not-track'

const isDNT = doNotTrackEnabled()
if (!isDNT) {
  // run tracking stuff