小编Sha*_* Sh的帖子

如何在网站中为Facebook像素创建选择退出选项?

**我在寻找:**我正在寻找的是,如何限制我网站上的facebook像素来跟踪并将我的网站用户信息发送到Facebook.

我已经知道的: Facebook像素跟踪用户的数据,如谷歌标签.但Google提供了一个脚本,允许用户选择此选项,这意味着将跟踪用户的信息,但不会将其发送给Google.

以下是google(来源)提供的退出选项代码:

<script>
// Set to the same value as the web property used on the site
var gaProperty = 'UA-XXXX-Y';

// Disable tracking if the opt-out cookie exists.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}

// Opt-out function
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
</script>
Run Code Online (Sandbox Code Playgroud)

现在我想为我的facebook像素提供类似的选项,因此用户可以禁用Facebook上的数据跟踪.我实际使用的是facebook提供的代码,用于跟踪我网站上特定事件的信息.这是我现在使用的代码(来源):

<!-- Facebook Pixel Code …
Run Code Online (Sandbox Code Playgroud)

facebook facebook-pixel

5
推荐指数
1
解决办法
4327
查看次数

标签 统计

facebook ×1

facebook-pixel ×1