-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Describe the bug
When Google Consent Mode v2 (GCM) is enabled, region rulesets configured under the default implementation “Google tag (gtag.js)” remain active even after switching the implementation to “Google Tag Manager (GTM) template”. This leads to conflicting behavior where the old gtag.js region rulesets can override consent configuration that is set up via GTM.
Steps to reproduce
- Go to Cookie Consent → Settings → Consent mode.
- Enable Google Consent Mode v2 (GCM).
- Ensure the implementation is set to Google tag (gtag.js) (default).
- Configure one or more regions using the gtag.js implementation. Save changes.
- Switch the implementation to Google Tag Manager (GTM) template. Save changes.
- Configure consent/regions via GTM (e.g. using the Pressidium Cookie Consent tag template).
- Using the GTM previewer, observe that behavior still reflects (or is overridden by) the previously configured gtag.js region rulesets, despite GTM template being selected.
Expected behavior
When the user switches the GCM implementation from gtag.js to GTM template, any region rulesets and related logic belonging to the gtag.js implementation should be disabled/unloaded (not applied on the frontend) unless gtag.js is the selected implementation.
Environment
- Plugin version: 1.9.1
- WordPress version: 6.9
- PHP version: 8.5
Additional context
This seems like an implementation “leak” between two mutually exclusive modes. If region rulesets are stored in shared settings and always injected/applied regardless of selected implementation, switching to GTM template effectively runs GTM configuration plus the gtag.js regional overrides.
Suggested fix
When GTM template is selected, prevent the plugin from outputting/applying any gtag.js-specific region rulesets (and vice versa). At minimum, unload/disable the previously configured gtag.js region rulesets at runtime when that implementation is not selected, so GTM can be the single source of truth for regional consent behavior.