• Resolved llmarlou

    (@llmarlou)


    Hi,

    We’ve noticed a possible bug with the Google Tag Manager (GTM) option of the Cookiebot plugin. It seems as if the GTM functionality can’t be disabled properly (after enabling).

    We noticed this in a site of on of our clients but I was able to reproduce this in a local basic installation using a basic Twenty-something theme (and running WP 5.8.3).

    To reproduce:
    1. At the ‘Google Tag Manager’ options page (admin.php?page=cookiebot_GTM), check the ‘Enable GTM’ checkbox, fill in a GTM ID and save changes.
    2. Load front-end of the website and lookup the following code output in the <head>

    <script>
    		(function (w, d, s, l, i) {
    		w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'});
    		var f = d.getElementsByTagName(s)[0],  j = d.createElement(s), dl = l !== 'dataLayer' ? '&l=' + l : '';
    		j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
    		f.parentNode.insertBefore(j, f);})(
    		window,
    		document,
    		'script',
    		'dataLayer',
    		'GTM-YOURID'
    	);
    </script>

    4. Next, go back to the plugin’s GTM settings and remove your GTM ID and uncheck ‘Enable GTM’
    5. Check the site’s source code again and you’ll notice the same output is still there, but without the GTM ID.

    <script>
    		(function (w, d, s, l, i) {
    		w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'});
    		var f = d.getElementsByTagName(s)[0],  j = d.createElement(s), dl = l !== 'dataLayer' ? '&l=' + l : '';
    		j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
    		f.parentNode.insertBefore(j, f);})(
    		window,
    		document,
    		'script',
    		'dataLayer',
    		''
    	);
    </script>

    What we expect to happen (when we uncheck ‘Enable GTM’ option) is that the code would be removed entirely.

    It now also shows an error/warning when you inspect the page (because of the missing GTM ID).

    Firefox
    Loading failed for the <script> with source “https://www.googletagmanager.com/gtm.js?id=”.

    Chrome
    Failed to load resource: the server responded with a status of 400 ()

    It seems as if the ‘Enable GTM’ checkbox/setting is not saving correctly.

    Please let me know if you need any more information.

    • This topic was modified 2 years, 9 months ago by llmarlou.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug with GTM functionality’ is closed to new replies.