I need to add a cookie consent system on our website due to GDPR laws. Currently everything is set to disable and enable the cookies, but I can't seem to delete third party cookies which are created by Google Analytics or AddThis (some social media tracking), because I can't find them with document.cookie.
So does anybody know what the best option is to either:
- Delete the third party cookies
- Prevent the scripts from running at start and launch the script after the user consents
- Run the scripts from the start, but unload the scripts if the user declines the usage of cookies
But just to be clear, I know how to remove regular cookies, I really need to find a way to remove the third party cookies or prevent them from being loaded (yet make sure they load when the user wants it)
<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>

