> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.cookiewow.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Update to Google Consent V2

Update to Google Consent V2

This article will guide you on how to update Google Consent to Version 2. You can find the official information[ __here__](https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#set_up_consent_mode).
1. Check your current <script> tag that's working with Google Tag or Google Analytics.Example (before the update):
```
<script async src="<https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX>"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());
  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'analytics_storage': 'denied'
  });
  gtag('config', 'G-XXXXXXXXXX');
</script>
```

Because Google Consent V2 requires additional consent flags.

2. Add the additional consent values. Your updated code should look like this:
```
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied'
});
```
These two lines are the additional settings:

```
 'ad_user_data': 'denied',
  'ad_personalization': 'denied',
```

Also, you need to add those at

```
<script>
  function consentGrantedAdStorage() {
    gtag('consent', 'update', {
      'ad_user_data': 'granted'
    });
    gtag('consent', 'update', {
      'ad_personalization': 'granted'
    });
  }
</script>
```
This is the final version of the script with Cookie Wow:

```
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    window.dataLayer.push(arguments);
  }

  // Initialize Google Analytics with default consent settings
  gtag('js', new Date());

  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'analytics_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
  });

  // Define wrapper to update consent if user accepts
  function cwcCookieWrapper() {
    if (window.cwcIsUserAccept && window.cwcIsUserAccept('analytics')) {
      gtag('consent', 'update', {
        'analytics_storage': 'granted'
      });
    }

    if (window.cwcIsUserAccept && window.cwcIsUserAccept('marketing')) {
      gtag('consent', 'update', {
        'ad_storage': 'granted',
        'ad_user_data': 'granted',
        'ad_personalization': 'granted'
      });
    }
  }
</script>
```

Now you can test it.