内容安全政策可以与Google Analytics和AdSense兼容吗? [英] Can Content Security Policy be made compatible with Google Analytics and AdSense?

查看:242
本文介绍了内容安全政策可以与Google Analytics和AdSense兼容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何通过默认src通配符获得CSP,以便现代Google Analytics脚本向网站所有者的帐户发送网站每页数据(不仅仅是主页数据),AdSense广告就会出现吗?



我为我的网站尝试了许多CSP版本,包括在< H5BP.com>的.htaccess文件中提出的CSP版本,页面数据(主页除外)和Google AdSense不接受任何网页上的广告。



Google的机器没有看到Google Analytics脚本,尽管Google的人员总是在我的视图中看到它网站源代码。即使将CSP default-src设置为星号通配符失败。



在Google论坛和非Google论坛上询问没有任何效果,只是人们说问题出在我的CSP和我收到一封电子邮件,说我应该完全评论CSP。最后的工作。注释掉应该不会比default-src通配符更好,但注释掉是我获得广告和网站内数据的唯一方式。





没有堆栈溢出线程是关于CSP和AdSense。当我提议H5BP在他们的模型<。htaccess>中告诉用户这件事时,他们的受访者表示它适合他并将我介绍给你。



建议,是否有人在自己的Google Analytics帐户中看到特定页面的数据,并在运行.htaccess CSP时看到AdSense广告? >无。截至今天[9月8日]。我们禁用了CSP,因为Google框架来源特定于域 - > frame-src:... google.co.uk google.co.fr ...


Does anyone know how to get CSP, even with the default-src wildcard, to work so a modern Analytics script sends website per-page data (not just home page data) to the site owner's account and so AdSense ads appear?

I tried many variations of CSP for my website, including that proposed in <H5BP.com>'s .htaccess file, but all blocked Google Analytics from producing per-page data (except for the home page) and Google AdSense from accepting ads on any page.

Google's machines did not see the Analytics script although Google's humans always saw it in my website source code. Even setting CSP default-src to the asterisk wildcard failed.

Asking at a Google forum and a non-Google forum got nothing that worked except that people said the problem was with my CSP and I received one email that said that I should comment CSP out completely. That last worked. Commenting out should be no better than default-src wildcard but commenting out is the only way I got ads and inside-the-website data.

No Stack Overflow thread is about CSP and AdSense. When I proposed that H5BP tell users about this in their model <.htaccess>, their respondent said it works for him and referred me to you.

As a check on advice, is anyone seeing that page-specific data in their own Google Analytics account and seeing AdSense ads while running .htaccess CSP?

解决方案

No. As of today [8 Sep 16]. We disabled CSP as Google frame source was domain specific -> frame-src : … google.co.uk google.co.fr ...

这篇关于内容安全政策可以与Google Analytics和AdSense兼容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆