Google Consent Mode v2 (UPDATED)

Google Consent Mode is a new way to ensure a website’s cookies and visitor data comply with GDPR and other data privacy regulations.

To continue using Google Ads or Google Analytics and target European users, you must implement Google Consent Mode v2 by March 2024.

For more information about Google, Consent Mode, read the official Google documentation https://developers.google.com/tag-platform/security/guides/consent

We have added the full functionality in version v4.3.2 of Joomla's Cookies Policy Notification Bar!

What's new in Consent Mode v2

Google Consent Mode v2 adds two new consent states, the  ad_user_data which is used to set consent for sending user data to Google for advertising purposes, and the ad_personalization which controls whether data can be used for ad personalization (e.g. remarketing).

Let's see step by step how you can implement the Google Consent Mode v2

Step 1 (for Google Analytics, Ads, Google Tag Manager).

Navigate to the plugin settings, click the Advance Settings tab, and then scroll down to the "Block Cookies by blocking their Javascript Code".

Choose the Google Analytics Category and place the code below. Remember to replace the G tags with yours. 

In the parameter field " When to Load this Script", you should check "All time" because you need to store the user even if not consent. No cookies are stored here.

<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
</script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-123456789A"></script>

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-123456789A'); // Google Analytics
gtag('config', 'GTM-1234ABC'); // Google Tag Manager
gtag('config', 'AW-111-222-1234'); // Google Ads
gtag('config', 'AW-123456789'); // Google Ads
</script> 


Step 2

Create another cookie script by clicking the green plus icon.

Choose the Google Analytics Category and place the code below. 

In the parameter field " When to Load this Script", you should now check "Before user consents" because you need to store the user even after consents.

<script>
// Google Analytics (before user consents)
gtag('consent', 'default', {
    'analytics_storage': 'denied',
    'functionality_storage': 'denied',
    'security_storage': 'granted',
});
</script>

Step 3

Create another cookie script by clicking the green plus icon.

Choose the Google Analytics Category and place the code below. 

In the parameter field " When to Load this Script", you should now check "After user consents" because you need to store the user even after consents.

<script>
// Google Analytics (after user consents)
gtag('consent', 'update', {
    'analytics_storage': 'granted',
    'functionality_storage': 'granted',
    'security_storage': 'granted',
});
</script> 

Step 4

Create another cookie script by clicking the green plus icon.

Choose the  Targeted Advertising Cookies, and place the code below. 

In the parameter field " When to Load this Script", you should now check "Before user consents" because you need to store the user even after consents.

<script>
// Google Ads (before user consents)
gtag('consent', 'default', {
    'ad_storage': 'denied',
    'functionality_storage': 'denied',
    'security_storage': 'granted',
    'personalization_storage': 'denied',
    'ad_personalization': 'denied',
    'ad_user_data': 'denied'
});
</script> 

Step 5

Create another cookie script by clicking the green plus icon.

Choose the  Targeted Advertising Cookies, and place the code below. 

In the parameter field " When to Load this Script", you should now check "After user consents" because you need to store the user even after consents.

<script>
// Google Ads (after user consents)
gtag('consent', 'update', {
    'ad_storage': 'granted',
    'functionality_storage': 'granted',
    'security_storage': 'granted',
    'personalization_storage': 'granted',
    'ad_personalization': 'granted',
    'ad_user_data': 'granted'
});
</script>

Of course, you can avoid steps 4 and 5 if you don't use Google Ads.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.