window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments) } window.amConsentManager = window.amConsentManager || { consentStates: { denied: 'denied', granted: 'granted' }, storageName: 'amConsentMode', gdprCookie: { cookieGroupName: 'amcookie_allowed', allCookiesAllowed: '0' }, defaultConsentTypesData: {"ad_storage":{"default":"0","group":"2"},"analytics_storage":{"default":"0","group":"3"},"ad_user_data":{"default":"0","group":"2"},"ad_personalization":{"default":"0","group":"2"}}, currentStoreId: 1, init: function () { this.initStorage(); this.setDefaultConsent(); }, initStorage: function () { const persistedConsentTypes = this.getPersistedConsentTypeState(); if (Object.keys(persistedConsentTypes).length !== 0 && !this.shouldResetConsentState(persistedConsentTypes)) { return; } let consentState = {}; for (const [type, data] of Object.entries(this.defaultConsentTypesData)) { consentState[type] = { group: data.group, status: data.default === '1' ? this.consentStates.granted : this.consentStates.denied }; } this.resetAllowedCookiesGroups(); this.persistConsentTypeState(consentState); }, setDefaultConsent: function () { gtag('consent', 'default', this.getPersistedConsentTypeStateForGtag()); }, updateConsent: function (consent) { const storageConsent = this.getPersistedConsentTypeState(); const consentState = {...storageConsent, ...consent}; this.persistConsentTypeState(consentState); gtag('consent', 'update', this.getPersistedConsentTypeStateForGtag()); }, getConsentTypeStateByGroupIds: function (groups) { let consentTypeState = {}; for (const [type, data] of Object.entries(this.defaultConsentTypesData)) { consentTypeState[type] = { group: data.group, status: (groups.includes(data.group) || groups.includes(this.gdprCookie.allCookiesAllowed)) ? this.consentStates.granted : this.consentStates.denied } } return consentTypeState; }, persistConsentTypeState: function (consentTypeState) { let persistedState = this.getPersistedConsentTypeState(false); persistedState[this.currentStoreId] = consentTypeState; localStorage.setItem(this.storageName, JSON.stringify(persistedState)); }, getPersistedConsentTypeState: function (forCurrentStore = true) { let persistedStates = JSON.parse(localStorage.getItem(this.storageName)) ?? {}; if (forCurrentStore) { return persistedStates?.[this.currentStoreId] ?? {}; } return persistedStates; }, getPersistedConsentTypeStateForGtag: function () { let consentTypeState = {}; let persistedState = this.getPersistedConsentTypeState(); for (const [type, data] of Object.entries(persistedState)) { consentTypeState[type] = data.status; } return consentTypeState; }, shouldResetConsentState: function (persistedConsentTypes) { if (Object.keys(persistedConsentTypes).length != Object.keys(this.defaultConsentTypesData).length || !document.cookie.includes(this.gdprCookie.cookieGroupName) ) { return true; } for (const [type, data] of Object.entries(persistedConsentTypes)) { if (data.group !== this.defaultConsentTypesData[type].group) { return true; } } return false; }, resetAllowedCookiesGroups: function () { document.cookie = this.gdprCookie.cookieGroupName + '=0;max-age=-1;domain=' + location.hostname; } }; window.amConsentManager.init();

Cadouri

Filtrat dupa
Vizualizare ca Grila Lista

4 Produse

pe pagina
Setati descendent
Vizualizare ca Grila Lista

4 Produse

pe pagina
Setati descendent