gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:24:24 26 4
gpt4 key购买 nike

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

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

这是谷歌提供的退出选项的代码(source):

<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>

现在我想为我的 facebook 像素提供一个类似的选项,这样用户就可以禁用来自 facebook 的数据跟踪。我实际使用的是 facebook 提供的代码,它跟踪有关我网站上特定事件的信息。这是我现在使用的代码(source):

<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', 'FB_PIXEL_ID');
fbq('track', 'PageView');
</script>
<!-- Insert Your Facebook Pixel ID below. -->
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=FB_PIXEL_ID&amp;ev=PageView&amp;noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

最佳答案

我创建了一个选择退出系统,它可以选择退出 GA 和 FB 跟踪,结合已有的许多代码源。我在这里发布了详细信息:https://stackoverflow.com/a/51217955/3817964

我不仅想从 GA 和 FB 中删除开发人员跟踪,而且我还想让公司内的一些人不被计入 GA 和 FB。因此,我想要一种相对简单的方法,让这些人无需插件即可将自己排除在分析之外,或者排除域 ip(因为有笔记本电脑的人会四处游荡)。

created a webpage用户可以转到并单击链接以选择退出 GA 和 FB 跟踪。它为站点放置一个 cookie。然后我检查那个 cookie 以确定我们是否应该将数据发送到 GA 和 FB。

关于facebook - 如何在网站中为 Facebook 像素创建退出选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47776687/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com