I want to make a revoke button what delete google analytics cookies _ga
and _gid
My JS code:
$('.wpca-btn-reset-consent').click(function(e) {
var domainValue = "www.mysite.eu";
document.cookie = '_ga=; path=/; domain=' domainValue '; expires=' new Date(0).toUTCString();
document.cookie = '_gid=; path=/; domain=' domainValue '; expires=' new Date(0).toUTCString();
alert("Done");
});
After I press button I get Done alert but cookies are not deleted.
CodePudding user response:
create a function and then try this way
function deleteCookie(yourName) { document.cookie = yourName '=; yourPath=/; yourDomain=.example.com; Expires=Thu, 30 Jan 2023 00:00:01 GMT;'; }
CodePudding user response:
My function works fine, my problem was that domain name was not correct.