使用JavaScript检测“不跟踪”

Do Not Track is an excellent idea.  The DNT website describes it best:

不追踪是个好主意。 DNT网站最好地描述了它:

Do Not Track is a technology and policy proposal that enables users to opt out of tracking by websites they do not visit, including analytics services, advertising networks, and social platforms. At present few of these third parties offer a reliable tracking opt out, and tools for blocking them are neither user-friendly nor comprehensive. Much like the popular Do Not Call registry, Do Not Track provides users with a single, simple, persistent choice to opt out of third-party web tracking.

“请勿追踪”是一项技术和政策建议,可让用户选择不访问的网站(包括分析服务,广告网络和社交平台)退出追踪。 目前,这些第三方中很少有提供可靠的跟踪退出功能,并且阻止它们的工具既不友好也不友好。 就像流行的“请勿呼叫”注册表一样,“不跟踪”为用户提供了一个简单,持久的选择,以选择退出第三方Web跟踪。

The preference is sent from the client to the server via a HTTP header but you can also get its value using JavaScript:

该首选项是通过HTTP标头从客户端发送到服务器的,但您也可以使用JavaScript获取其值:


// "1" or "unspecified"
if(navigator.doNotTrack == 1) {
    // Do (or don't do) stuff.
}


If you wanted to be extreme about honoring your user's preference, you could use that to lazyload (or not) advertising, analytics, or other utilities. Probably a bit extreme but it's there for you to use!

如果您想极端地尊重用户的偏好,则可以使用它来延迟加载(或不延迟加载)广告,分析或其他实用程序。 可能有点极端,但是它可供您使用!

翻译自: https://davidwalsh.name/detect-track-javascript

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值