How to Allow Google Analytics to Collect Anonymous Statistics Before User Consent (Google Tag Manager Setup)
How to Allow Google Analytics to Collect Anonymous Statistics Before User Consent (Google Tag Manager Setup)
If you're using Google Analytics via Google Tag Manager (GTM) and want to collect data anonymously before users give consent, here’s a step-by-step guide.
For websites using Google Analytics installed directly via HTML (not through GTM), refer to this guide: Read setup instructions here
If your website collects personally identifiable information (PII) for analysis or marketing purposes, you must first obtain user consent according to PDPA laws.
However, to ensure accurate visitor statistics — regardless of consent — you can anonymize data before consent is granted to reduce privacy risks.
Before consent is given, configure Google Analytics to:
Not use cookies
Not collect granular identity details
Use anonymized IP by default ( more info)
Once consent is granted via the Cookie Wow banner, allow normal data collection with cookies.
Place the following in the “Necessary” group, not “Analytics”:
https://www.googletagmanager.com/gtm.js?id=<GTM-KEY>
https://www.google-analytics.com/analytics.js
Open GTM, go to the Variables tab.

Create a new Custom JavaScript Variable.

Use this snippet (replace 'category-slug' with the actual category slug you're using, usually 'Analytics'):
You can find the correct slug used in your Cookie Wow settings here: How to find slugs
Set "Convert null to false" and "Convert undefined to false"
Name it something like cwcIsUserAcceptConsent, then Save

Name: Page View Trigger without User Consent
Type: Page View → Some Page Views
Condition: cwcIsUserAcceptConsent equals false

Name: Page View Trigger with User Consent
Type: Page View → Some Page Views
Condition: cwcIsUserAcceptConsent equals true

Name it: Universal Analytics without User Consent
Tag Type: Google Analytics: Universal Analytics
Track Type: Page View
Google Analytics Settings: Use your Tracking ID
Enable "Override settings in this tag"
Under More Settings, add these fields:

Set Trigger to: Page View Trigger without User Consent

Name it: Universal Analytics with User Consent
Tag Type: Google Analytics: Universal Analytics
Track Type: Page View
Use your GA Tracking ID
Set Trigger to: Page View Trigger with User Consent

If you're using Google Analytics via Google Tag Manager (GTM) and want to collect data anonymously before users give consent, here’s a step-by-step guide.
For websites using Google Analytics installed directly via HTML (not through GTM), refer to this guide: Read setup instructions here
Note:
If your website collects personally identifiable information (PII) for analysis or marketing purposes, you must first obtain user consent according to PDPA laws.
However, to ensure accurate visitor statistics — regardless of consent — you can anonymize data before consent is granted to reduce privacy risks.
Principle:
Before consent is given, configure Google Analytics to:
Not use cookies
Not collect granular identity details
Use anonymized IP by default ( more info)
Once consent is granted via the Cookie Wow banner, allow normal data collection with cookies.
Step-by-Step Setup via Google Tag Manager
❶ Move the GTM & Analytics tags to the “Necessary” category:
Place the following in the “Necessary” group, not “Analytics”:
https://www.googletagmanager.com/gtm.js?id=<GTM-KEY>
https://www.google-analytics.com/analytics.js
❷ Create a Variable to Check Consent Status
Open GTM, go to the Variables tab.

Create a new Custom JavaScript Variable.

Use this snippet (replace 'category-slug' with the actual category slug you're using, usually 'Analytics'):
function() {
return window.cwcIsUserAccept('category-slug');
}
You can find the correct slug used in your Cookie Wow settings here: How to find slugs
Set "Convert null to false" and "Convert undefined to false"
Name it something like cwcIsUserAcceptConsent, then Save

❸ Create Two Triggers (With/Without Consent)
A. Trigger for Users Who Have Not Given Consent
Name: Page View Trigger without User Consent
Type: Page View → Some Page Views
Condition: cwcIsUserAcceptConsent equals false

B. Trigger for Users Who Have Given Consent
Name: Page View Trigger with User Consent
Type: Page View → Some Page Views
Condition: cwcIsUserAcceptConsent equals true

❹ Create Two GA Tags (One with, One without Consent)
A. Tag for Users Without Consent (Anonymous Tracking)
Name it: Universal Analytics without User Consent
Tag Type: Google Analytics: Universal Analytics
Track Type: Page View
Google Analytics Settings: Use your Tracking ID
Enable "Override settings in this tag"
Under More Settings, add these fields:
storage: none
storeGac: false
anonymizeIp: true

Set Trigger to: Page View Trigger without User Consent

B. Tag for Users With Consent (Normal Tracking)
Name it: Universal Analytics with User Consent
Tag Type: Google Analytics: Universal Analytics
Track Type: Page View
Use your GA Tracking ID
Set Trigger to: Page View Trigger with User Consent

Updated on: 29/05/2025
Thank you!