document.addEventListener('mhcookie/gcmv2', function(){
const consentTypes = mhCookie.consentTypes;
// Reset consents
Object.keys(consentTypes).forEach(function(key){
if(key !== 'security_storage'){
consentTypes[key] = 'denied';
}
});
if (mhCookie.userConsent.groups.includes('all') || mhCookie.userConsent.groups.includes('marketing')){
Object.keys(consentTypes).forEach(function(key){
consentTypes[key] = 'granted';
});
}
if (mhCookie.userConsent.groups.includes('analytics')){
consentTypes.analytics_storage = 'granted';
}
if (mhCookie.userConsent.groups.includes('functional') || mhCookie.userConsent.groups.includes('other')){
consentTypes.functionality_storage = 'granted';
}
dataLayer.push({event: "cookie_consent_update", consentTypes);
});