Support » Plugins and Hacks » [Resolved] Container snippet NOT immediately after

[Resolved] Container snippet NOT immediately after

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author lauraeus


    Thank you for that note!
    Due to the lack of hooks in wp core we had to choose between placing the tag manager snippet in “html head” or at the bottom of the page. The corresponding hooks are “wp-head” and “footer” respectivly.

    For the non-programming geeks, this meens absolutely nothing.

    In order to meet the Google recommendation as closely as possible, this plugin activates the Google Tag Manager snippet in the head, but awaits the “body” document object to become available and thereafter attaches itself to this element. Just as Google prescribes.

    Hope this helps and clears the issue a little bit?


    Hi, I just watched a webinar about GTM. The reason we should put the GTM snippet just after the <body> tag is to ensure that GTM works on browsers w/o Javascript activated. So.. for all browsers that are JS enabled there is no need to put it after the <body>, it should work as well as inside the <head> section.

    I’m telling you that because I saw (i just installed your plugin, thx) that the code you wrote has no “<noscript>” section. So.. you put the GTM just after the <body> but you ripped off the <noscript> section which is the very reason to move that code in that position.

    May you try to attach to the GTM the <noscript> section?? Thx.

    In fact, using JS to move the code after the <body> means that on JS non-enabled browsers will not work. The iframe tag cannot be executed inside the <head> on a nonJS browser. That’s why we need to put the GTM (script + noscript) just after the <body>.

    Plugin Author lauraeus


    The <noscript> will always be added to the footer as you aldready may have noticed.

    The other issue regarding loading of GTM snippet in HEAD section of a page is another matter. By doing so you would get into a lot of timing problems with especially Internet Explorer. The GTM snippet tries to attach to the Body DOM object. If snippet is loaded in HEAD the BODY may not be yet available. This is a serious problem an will fail a lot of visitors.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Container snippet NOT immediately after’ is closed to new replies.