Last active
July 5, 2018 14:42
-
-
Save zoetrope69/b3dc083fdc6f4dee12c233574acbc97a to your computer and use it in GitHub Desktop.
Example of detecting Do Not Track on the client side
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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