Cookieconsent-“撤销”选项不起作用

时间:2019-04-09 11:41:43

标签: cookies

我正在使用“选择加入”选项(默认情况下未加载cookie)测试cookieconsent脚本on my website

启用和禁用作品,但是当我想撤消(左下角的小按钮)时,什么也没发生。这些是我启用/禁用Cookie的功能:

function enableCookies() {
   window.dataLayer = window.dataLayer || [];
   function gtag(){dataLayer.push(arguments);}
   gtag('js', new Date());
   gtag('config', 'UA-17530048-4');
}
function disableCookies() {
   window['ga-disable-UA-17530048-4'] = true;
}

在“启用”上,我只是激活了Google Analytics(分析)脚本,在“停用”上,我使用了“ ga-disable”功能,但它似乎不起作用。

这是整个脚本:

function enableCookies() {
   window.dataLayer = window.dataLayer || [];
   function gtag(){dataLayer.push(arguments);}
   gtag('js', new Date());
   gtag('config', 'UA-17530048-4');
}
function disableCookies() {
   window['ga-disable-UA-17530048-4'] = true;
}
window.addEventListener("load", function(){
window.cookieconsent.initialise({
    "palette": {
        "popup": {
            "background": "#222",
            "text": "#fff"
        },
        "button": {
            "background": "#ccc",
            "text": "#222"
        },

    },
    "type": "opt-in",
    "revokable": "false",
    "animateRevokable": "false",
    "content": {
        "message": "Message",
        "deny": 'No - Cookies are bad',
        "allow": "YES - I love cookies",
        "link": "More info",
        "href": "https://www.google.de"
    },
    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()
        }
    },
})
});

0 个答案:

没有答案