跟踪 DNT 异常处理

Tracking DNT Exception handling

目前我正在尝试解决有关跟踪的问题。

在我们的网站上,用户应该能够决定他是否被跟踪以及分享哪种信息。

我们还有不同的第三方跟踪机制,也可以关闭。 (如果用户愿意)

我用本地存储 + cookie 解决了这个问题。如果用户决定停用我们的其中一项跟踪,负责这种跟踪的代码将不会通过请求的文件传输。

此外,我确实尊重 window.Navigator.doNotTrack 的设置,在蜂鸣 1​​ 的情况下,会在弹出的快餐栏中解析并请求许可。

我找到的关于这个主题的所有信息是 here

我想知道的是如何申请破例,以及如何查看该网站是否被接受。

我尝试了here描述的方法,但它似乎不起作用。

Navigator.trackingExceptionExists // will be undefined

你可以试试

navigator.confirmSiteSpecificTrackingException

查看下面的内容link以获取完整参考

https://msdn.microsoft.com/en-us/library/dn265021(v=vs.85).aspx

DNT header 字段是一种在 HTTP 请求中表达用户跟踪偏好的机制。最多一个 DNT header 字段可以出现在一个有效的请求中。

DNT-field-name = "DNT"

DNT-field-value = ("0" / "1") *DNT-extension

  • 如果用户的 跟踪首选项未启用
  • 用户代理必须生成带有field-value的DNT header字段 如果用户的跟踪以数字字符 "1" 开头 首选项已启用,他们的首选项是 DNT:1,没有 已为请求目标授予例外。
  • 用户代理必须生成一个带有 field-value 的 DNT header 字段 以数字字符 "0" 开头,如果用户的跟踪 首选项已启用,他们的首选项是 DNT:0,或者如果 已为请求目标授予例外。
  • A proxy 不得 生成 DNT header 字段,除非它已被 由用户专门安装或配置为这样做 像用户一样请求并遵守上述要求 代理。

这里有一些方法请求Site-specific异常:

  1. void storeSiteSpecificTrackingException (StoreSiteSpecificExceptionPropertyBag properties)

    This is called by a page to store a site-specific tracking exception. The storeSiteSpecificTrackingException method takes a dictionary argument of type StoreSiteSpecificExceptionPropertyBag that allows optional information to be provided.

  2. DOMString?域

    This is a cookie-domain to which the exception applies.

  3. DOMString?站点名称

    A user-readable string for the name of the top-level origin.

  4. DOMString?说明字符串

    A short explanation of the request.

  5. DOMString? detailURI

    A location at which further information about this request can be found.

  6. DOMString?到期

    A date and time, encoded as described for the cookie expires attribute indicating the maximum lifetime of the remembered grant.

  7. 长?最大年龄

    A positive number of seconds indicating the maximum lifetime of the remembered grant.

  8. 序列 arrayOfDomainStrings

    A JavaScript array of strings. If the request does not include the arrayOfDomainStrings, then this request is for a site-wide exception. Otherwise each string in arrayOfDomainStrings specifies a target. When called, storeSiteSpecificTrackingException MUST return immediately. If the list arrayOfDomainStrings is supplied, the user agent MAY choose to store a site-wide exception. If it does so it MUST indicate this in the return value.

因此,作为第一个问题 如何请求例外处理? 的答案,我建议您这样做:

Navigator.storeSiteSpecificTrackingException

如果您想删除权限授予,请执行以下操作:

Navigator.removeSiteSpecificTrackingException

There is no callback for removeSiteSpecificTrackingException. After the call has been made, it is assured that there are no site-specific or site-wide exceptions for the given top-level origin.

作为你第二个问题的答案如何查看网站上的例外偏好是否被接受? , confirmSiteSpecificTrackingException 是用于相同的方法:

boolean confirmSiteSpecificTrackingException (ConfirmSiteSpecificExceptionPropertyBag properties)

This method is called by a page to confirm a site-specific tracking exception.

所以你所要做的就是:

Navigator.confirmSiteSpecificTrackingException