commercekings / module-consent-google-tag
Consent for Magento's native Google tags (GA4, Universal Analytics, Google Ads via gtag) with Google Consent Mode v2, independent of the cookie banner.
Package info
github.com/commercekings/module-consent-google-tag
Language:JavaScript
Type:magento2-module
pkg:composer/commercekings/module-consent-google-tag
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0||~8.5.0
- commercekings/consent-source: ^0.1
- commercekings/module-consent: ^0.1
- magento/framework: ^103.0.5
- magento/module-store: ^101.1
Requires (Dev)
None
Suggests
- commercekings/module-consent-vanilla: A consent banner. Or any package that provides commercekings/consent-source.
- magento/module-google-analytics: Legacy Universal Analytics integration supported by this module
- magento/module-google-gtag: Native GA4 and Google Ads (gtag) supported by this module
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-19 17:35:32 UTC
README
Works with Magento 2.4.5+ · Luma and Hyvä · PHP 8.1–8.5
Magento's own Google tags, only after consent – with Google Consent Mode v2.
- Nothing reaches Google before consent – GA4, Google Ads and legacy Universal Analytics.
- Google Consent Mode v2: all four signals, updated the moment a choice changes.
- Clean withdrawal. Google cookies are removed; Ads stops on the next page.
- No new settings. Configure Google where Magento already has it.
Installation
composer require commercekings/module-consent-google-tag:^0.1 commercekings/module-consent-vanilla:^0.1 bin/magento setup:upgrade
It needs a consent banner – ours or any package that provides commercekings/consent-source; Composer refuses to
install it without one.
What it covers
Configure the tags where Magento has them – Stores > Configuration > Sales > Google API:
| Magento setting | Purpose (banner category) | Consent Mode signals |
|---|---|---|
| Google GTag > Google Analytics4 | google_analytics (Analytics) |
analytics_storage |
| Google Analytics (legacy UA) | google_analytics (Analytics) |
analytics_storage |
| Google GTag > Google AdWords | google_ads (Marketing) |
ad_storage, ad_user_data, ad_personalization |
Limitations
- Legacy Google AdWords (Google API > Google Analytics > Google AdWords) is not gated – keep it off and use Google GTag > Google AdWords.
- Google Tag Manager and tags pasted into the theme load without consent.
Check the live result with Google's Tag Assistant.
Tested (as of 0.1.0)
- Automated tests: 10 unit and 34 JavaScript tests (GA4, Google Ads, legacy Universal Analytics, Consent Mode v2, Hyvä) (unit and JavaScript tests run on every push); 94.7% line coverage by the unit tests.
- Install: a fresh install of every CommerceKings package from GitHub on an empty Magento database, verified.
- Not tested: live in Google Tag Assistant, and end to end in a browser.
More
How it works · Compatibility · Changes
Disclaimer
These modules help you ask for, record and respect your shoppers' choices – they don't make your store compliant on their own. You are responsible for your store's privacy: what you collect, the wording you show, your privacy policy and whether your setup meets the laws that apply to you (e.g. GDPR, ePrivacy, email marketing rules). Get legal advice if you are unsure.
Need it installed, set up or customized? Get in touch →