由于GDPR法律的原因,我需要在我们的网站上添加Cookie同意系统。目前,所有功能都设置为禁用和启用Cookie,但是我似乎无法删除由Google Analytics(分析)或AddThis(某些社交媒体跟踪)创建的第三方Cookie,因为我无法使用document.cookie
找到它们
有人知道哪个是最好的选择吗?
但是要清楚一点,我知道如何删除常规Cookie,我确实需要找到一种方法来删除第三方Cookie或阻止第三方Cookie加载(但请确保在用户需要时加载第三方Cookie) )
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-556d15415fgddz4536" async="async"></script>
<script>
function enableCookies() {
console.log('enable cookies');
}
function disableCookies() {
console.log('disable cookies');
}
window.cookieconsent.initialise({
onInitialise: function (status) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
enableCookies();
}
if (type == 'opt-out' && !didConsent) {
disableCookies()
}
},
onStatusChange: function (status, chosenBefore) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
enableCookies();
}
if (type == 'opt-out' && !didConsent) {
disableCookies()
}
},
onRevokeChoice: function () {
var type = this.options.type;
if (type == 'opt-in') {
disableCookies()
}
if (type == 'opt-out') {
enableCookies();
}
}
position: "bottom-left",
type: "opt-out"
});
</script>