Skip to content

Instantly share code, notes, and snippets.

@zoetrope69
Last active July 5, 2018 14:42
Show Gist options
  • Save zoetrope69/b3dc083fdc6f4dee12c233574acbc97a to your computer and use it in GitHub Desktop.
Save zoetrope69/b3dc083fdc6f4dee12c233574acbc97a to your computer and use it in GitHub Desktop.
Example of detecting Do Not Track on the client side
function isDoNotTrackEnabled () {
const doNotTrackOption = (
window.doNotTrack ||
window.navigator.doNotTrack ||
window.navigator.msDoNotTrack
)
if (!doNotTrackOption) {
return false
}
if (
doNotTrackOption.charAt(0) === '1' ||
doNotTrackOption === 'yes'
) {
return true
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment