0

First sorry for my bad english, I'm french. I have a WordPress website and I need to make it compliant for GDPR. So I need to find a way to remove cookies, I make it with google analytics but they give a function to remove them. Here is what I do for the google analytics cookies (the function is_allowed_cookie is from a plugin) :

add_action( 'wp_head', 'my_google_opt_out' );
function my_google_opt_out() {
if ( ! is_allowed_cookie( '_ga' ) ) {
    ?>
    <script id="test_delete_ga">
        window['ga-disable-UA-XXXXX-X'] = true; // I have replace the XX with my number
    </script>
    <?php
} else {
    ?>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA- 
 XXXX-X" data-cookieconsent="statistics"></script>
    <script  data-cookieconsent="statistics">
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', 'UA-XXXX-X');
    </script>
    <?php
}
}

But now I want to do the same with other cookies, but they do not give a method to deregister them, how can i proceed ? For example I have some cookies from youtube (CONSENT, HSID, LOGIN_INFO,...)

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.