Ily*_*yas 6 adsense gdprconsentform
我的网站已经上线几年了,使用 AdSense 及其集成的 GDPR 内容功能,即在 IAB TCF 术语中,Google 充当 CMP。
在过去的几周里,我收到了以下消息“我们在您的一个或多个网站或应用程序上检测到您的 IAB TC 字符串存在问题。这些错误可能会影响您向欧洲用户投放广告的能力。详细报告为您可以在欧盟用户同意页面上获取”。
当我查看 AdSense 中的欧盟内容页面时,我可以看到下载 TCF 错误报告,我看到以下内容:
| 领域 | 广告单元 | 错误 | 错误计数 | 最后检测到的日期 |
|---|---|---|---|---|
| mydomain.com | 未知 | 3.3 | 120 | 15/03/2023 |
| mydomain.com | 9051459592 | 3.3 | 60 | 14/03/2023 |
| mydomain.com | 7113359331 | 3.3 | 20 | 12/03/2023 |
因此,所有错误都与同意有关(根据https://support.google.com/admanager/answer/9999955?hl=en),看起来我需要“删除旧的 TC 字符串并重新获得同意”。
我的问题是我不知道该怎么做。我可以使用哪些步骤来执行此操作?我直接使用 AdSense(广告单元和自动广告),因此看起来我需要征求用户的同意,但我不知道该怎么做。
任何人都可以建议我需要做什么才能减少此错误计数。我的网站每天大约有 25,000 个页面浏览量,因此上面提到的数字并不大,但最好完全没有任何 TCF 错误。
不幸的是,AdSense 的集成欧盟用户同意功能(使用 Google 的 Funding Choices API 提供同意管理平台)并没有提供自动方法,以便在 TC 字符串中捕获的原始同意达到 13 个月时提示重新同意。
在 Funding Choices 实现中,TC 字符串作为数据元素保留在名为 FCCDCF 的 cookie 中,TC 字符串本身包含提供同意的日期。为了保持与 IAB 的 TCF v2 框架的合规性,当 AdSense API 处理此字符串并发现同意已过期时,它会记录针对广告单元的政策违规(“错误 3.3”),并且不会呈现它们。但除了提供一个有点不透明的通知,表明存在一个可能“影响您向欧洲用户投放广告的能力”的问题之外,它对解决这种情况没有任何帮助!
因此,收入将随着时间的推移而下降,因为越来越多的访问者拥有包含不再与广告单元呈现兼容的同意的 TC 字符串。
要解决此问题,可以在 AdSense 实施之前添加以下 JavaScript(进行修改以匹配网站的 FCCDCF cookie 的域和路径),该 JavaScript 将从资助选择 cookie 中提取 TC 字符串,解析出同意日期,并然后,如果确定 12 个月前已提供同意,则删除 cookie。
/*
* Delete the Funding Choices cookie if consent is more than 12 months old.
*
* Version: 2 (2023-12-21)
*
* https://stackoverflow.com/a/76025628/2568535
*
*/
<script>
try {
const nm = "FCCDCF"; // Match name of Funding Choices cookie
const dm = "mydomain.com"; // Match domain of Funding Choices cookie
const pa = "/"; // Match path of Funding Choices cookie
let tc = ('; ' + document.cookie).split('; ' + nm + '=');
if (tc.length === 2) {
tc = decodeURIComponent(tc.pop().split(';').shift());
tc = JSON.parse(tc)[3][0].substring(1,9);
tc = tc.replace(/-/g, '+').replace(/_/g, '/');
tc = Uint8Array.from(window.atob(tc), (v) => v.charCodeAt(0));
let dt = (tc[0] * 2**28) + (tc[1] * 2**20) + (tc[2] * 2**12) +
(tc[3] * 2**4) + (tc[4] >> 4);
if (Date.now() / 1000 - dt / 10 > 86400 * 365)
document.cookie = nm + "=;path=" + pa + ";domain=" + dm +
";expires=" + new Date(0).toUTCString();
}
} finally {}
</script>
Run Code Online (Sandbox Code Playgroud)
注意:nm在上面的代码中,将变量和dm的字符串文字替换pa为标识资金选择 cookie 的参数。这些将取决于您的 AdSense 配置并且特定于您的安装。您可以通过查看网站的 cookie 在浏览器的开发者控制台中找到这些内容。
| 归档时间: |
|
| 查看次数: |
2837 次 |
| 最近记录: |