Google Tag Manager only load when connected to Admin

I've got this weird problem and I just don't know where to look : I've installed GTM tag on my wordpress site but it seems it's only being loaded when I'm connected as an admin.

How I can tell ? In GTM, i've setup the following simple tag

script type=text/javascript
  console.log('gtm test html tag');
/script

This code is only triggered when I'm connected to wp-admin.

PS : Here's other informations that I think may enter in play, but im not sure it's relevant :

  • elementor

  • wp Rocket

  • autoptimize

  • Also, when i'm in Preview mode in Google Tag Manager, every tag is triggered even when i'm not connect to wp-admin

Thanks in advance

Topic google-analytics Wordpress javascript google

Category Web


Ok, problem came from Autoptimize problem : there's an option, Also aggregate inline JS? , should be unchecked

There must be a way to exclude GTM script from Autoptimize, still haven't take a look yet !

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.