# Where does all the data get stored in the Cookie Consent widget?

**URL:** <https://community.elfsight.com/t/where-does-all-the-data-get-stored-in-the-cookie-consent-widget/84022>\
**Category:** General Questions\
**Tags:** cookie-consent\
**Created:** [November 19, 2024, 5:02pm UTC](https://community.elfsight.com/t/where-does-all-the-data-get-stored-in-the-cookie-consent-widget/84022 "2024-11-19T17:02:26Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [January 20, 2025, 12:21pm UTC](https://community.elfsight.com/t/where-does-all-the-data-get-stored-in-the-cookie-consent-widget/84022/12 "2025-01-20T12:21:25Z")

</div>

Hi there, @Hugh 👋

Thank you so much for the feedback!

While our widget doesn’t process cookies, I am happy to say that it’s possible to decline cookies, using a Google Analytics code and JS script to meet new cookie policy requirements.

Here are the scripts 🙂

Please add this part of the code to your website `<head>`:

```auto
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ID');
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'analytics_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'wait_for_update': 3000
});
</script>

```

  

In the code above, in the **1st** and **6th** lines you need to replace **G** - **ID** with your actual website ID for Google Analytics. This article will help you find your ID - [Find your Google tag ID](https://support.google.com/analytics/answer/9539598?hl=en).

Also, you can insert additional permissions (if required) after **11th** line of the script above after **‘ad\_personalization’: ‘denied’**. Please make sure you’ve added them in this format:  
‘your\_permission’: ‘denied’

And then add the rest of the script to the Custom JS section on the Appearance tab in the widget editor:

```auto
const consents = ['ad_storage', 'analytics_storage', 'ad_user_data', 'ad_personalization'];

function sendEvent(config) {
    if (typeof gtag !== "undefined") {
        gtag('consent', config.action, {
            ...config.consents
        });
    }
}

function eappsDispatchAnalyticsEvent(event, selector, config) {
    function isHitClass(e, selector) {
        return e.target && e.target.closest(selector);
    }
    if (isHitClass(event, selector)) {
        sendEvent(config);
    }
}

const getConfig = (status) => ({
    action: 'update',
    consents: {
        ...consents.reduce((res, consent) => {
            res[consent] = status;
            return res;
        }, {})
    }
});

const answer = JSON.parse(localStorage.getItem("cookie-consent.answer"));
switch (answer) {
    case 'allow':
        sendEvent(getConfig('granted'));
        break;
    case 'decline':
        sendEvent(getConfig('denied'));
        break;
    default:
        document.addEventListener('click', function (event) {
            eappsDispatchAnalyticsEvent(event, '.eapp-cookie-consent-actions-accept', getConfig('granted'));
            eappsDispatchAnalyticsEvent(event, '.eapp-cookie-consent-actions-decline', getConfig('denied'));
        });
        break;
}
In the script above you can insert additional permissions in the first line after ‘ad_personalization’:
const consents = ['ad_storage', 'analytics_storage', 'ad_user_data', 'ad_personalization', 'your_permission'];

```

  

> **Note:** it may take 48 hours for those updates to show up on Google Analytics.

Also, just a kindly reminder that our Cookie Consent widget should be installed on every page of your website to work correctly.

Test it out and let us know how it worked 🙂

  

By the way, we have a Wishlist request for the Cookie Consent with actual blocker. You can upvote this idea here - [Cookie consent with actual cookie blocker on decline](https://community.elfsight.com/t/cookie-consent-with-actual-cookie-blocker-on-decline/24473)

---

_[View the full topic](https://community.elfsight.com/t/where-does-all-the-data-get-stored-in-the-cookie-consent-widget/84022)._
