Problem/Motivation

When I "Accept All" or enable "Google Tag Manager" (see screenshot), extra code is injected into my website.
Screenshot of issue

If I don't allow the Google Tag Manager cookie, then this does not happen.

Is there an issue as to why this is happening?

The code it's spitting out is the following:

const dataLayerPush = require('createQueue')('dataLayer');
const gtagSet = require('gtagSet');
const log = require('logToConsole');
const makeNumber = require('makeNumber');
const makeTableMap = require('makeTableMap');
const setDefaultConsentState = require('setDefaultConsentState');
const updateConsentState = require('updateConsentState');
const eeaRegions = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "NO", "IS", "LI"];
const regions = data.regions || data.regionsEEA; // Determine the command and the setting object const consentApi = data.command === 'default' ? setDefaultConsentState : updateConsentState; const settingsObject = {}; if (data.ad_storage !== 'notset') settingsObject.ad_storage = data.ad_storage; if (data.analytics_storage !== 'notset') settingsObject.analytics_storage = data.analytics_storage; if (data.ad_user_data !== 'notset') settingsObject.ad_user_data = data.ad_user_data; if (data.ad_personalization !== 'notset') settingsObject.ad_personalization = data.ad_personalization; if (data.personalization_storage !== 'notset') settingsObject.personalization_storage = data.personalization_storage; if (data.functionality_storage !== 'notset') settingsObject.functionality_storage = data.functionality_storage; if (data.security_storage !== 'notset') settingsObject.security_storage = data.security_storage; // Settings specific to the "default" command if (data.command === 'default' && makeNumber(data.wait_for_update) > 0) { settingsObject.wait_for_update = makeNumber(data.wait_for_update); } if (data.command === 'default' && regions !== 'all') { let setRegions = regions.split(',').map(r => r.trim()); // Check if EEA regions are included if (setRegions.indexOf('eea') > -1) { setRegions = setRegions.concat(eeaRegions); // Remove duplicates & eea setRegions = setRegions.filter((val, idx) => setRegions.indexOf(val) === idx && val !== 'eea'); } settingsObject.region = setRegions; } // Set advanced settings gtagSet({ url_passthrough: data.url_passthrough || false, ads_data_redaction: data.ads_data_redaction || false }); // Set the consent state consentApi(settingsObject); // Push to dataLayer if needed if (data.sendDataLayer) { settingsObject.event = 'gtm_consent_' + data.command; dataLayerPush(settingsObject); } // Call data.gtmOnSuccess when the tag is finished. data.gtmOnSuccess();

Which is the consent mode code we have set in Google Tag Manager.

Not sure if the issue is this module or google_tag but figured I'd start here since it relates to the setting in the box being turned on or off.

Any ideas? I tried to see if this issue had already popped up here and the google_tag issue queue but didn't seem to find anything.

Steps to reproduce

Turn on this module, the COOKiES Google Tag Manager submodule and Google Tag Manager and allow Google Tag Manager cookies and this is what happens.

CommentFileSizeAuthor
footer-code.jpg454.04 KBsnowcoder

Comments

SnowCoder created an issue. See original summary.

anybody’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks @SnowCoder!

Can someone confirm or reproduce this for vanilla Drupal? I don't have an explanation yet, nor I saw this. Can you reproduce this at simplytest.me?