Title: Bug with GTM functionality
Last modified: February 16, 2022

---

# Bug with GTM functionality

 *  Resolved [llmarlou](https://wordpress.org/support/users/llmarlou/)
 * (@llmarlou)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/bug-with-gtm-functionality/)
 * 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 4 years, 3 months ago by [llmarlou](https://wordpress.org/support/users/llmarlou/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [aytac](https://wordpress.org/support/users/aytac/)
 * (@aytac)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/bug-with-gtm-functionality/#post-15403541)
 * Hello [@llmarlou](https://wordpress.org/support/users/llmarlou/),
 * Thanks for the report!
 * We just released a new version to address this!
 * Take care,
 * Aytac
 *  Thread Starter [llmarlou](https://wordpress.org/support/users/llmarlou/)
 * (@llmarlou)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/bug-with-gtm-functionality/#post-15403694)
 * Hi Aytac,
 * Thanks a lot! I’ve just updated to 4.0.3 and this fixes it indeed

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Bug with GTM functionality’ is closed to new replies.

 * ![](https://ps.w.org/cookiebot/assets/icon.svg?rev=3200631)
 * [Cookiebot by Usercentrics - Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode](https://wordpress.org/plugins/cookiebot/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookiebot/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookiebot/)
 * [Active Topics](https://wordpress.org/support/plugin/cookiebot/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookiebot/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookiebot/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [llmarlou](https://wordpress.org/support/users/llmarlou/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/bug-with-gtm-functionality/#post-15403694)
 * Status: resolved