Accessing the user's preferences in terms of tracking can be slightly complicated. This module simplifies that.
npm install --save donottrack
Browser:
import doNotTrack from 'donottrack';
// Returns true if the user do not want to be tracked, false otherwise.
const do_not_track = doNotTrack(/* default, if preferences are not set. */ false);Node:
import doNotTrack from 'donottrack';
const do_not_track = doNotTrack(req.header('DNT'), false);