Title: General technical question
Last modified: August 31, 2016

---

# General technical question

 *  [academyadmin](https://wordpress.org/support/users/academyadmin/)
 * (@academyadmin)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/general-technical-question/)
 * Hello,
 * I just want to make sure if this kind of behavior is normal, or if I should try
   to figure out why it happens:
 * I put the code:
    `<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag();}?
   >` right after <body> in header.php
 * When inspecting the DOM I can see that there are 2 blocks of code inserted by
   the plugin, one of them is all in the header (NO.#1), the other one spans across
   the <head> and <body> – it starts before </head> and ends after <body> (NO.#2).
 * Here’s an excerpt for (NO.#1):
 *     ```
       <!-- Google Tag Manager for WordPress by DuracellTomi - http://duracelltomi.com -->
   
       <em>a facebook scrips..
       tawk.to script..</em>
   
       <script type="text/javascript">
       	var gtm4wp_datalayer_name = "dataLayer";
       	var dataLayer = dataLayer || []
       </script>
       <!-- End Google Tag Manager for WordPress by DuracellTomi -->
       ```
   
 * Here’s an excerpt for (NO.#2):
 *     ```
       ... some <head> code here...
       <em><!-- Google Tag Manager for WordPress by DuracellTomi --></em>
       <script type="text/javascript">
       	dataLayer.push({"pagePostType":"page","pagePostType2":"single-page","pagePostAuthor":"MyWebsite"});
       </script>
           <strong></head></strong>
           <strong><body></strong>
       <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MyID"
       height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
       <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=
       '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
       })(window,document,'script','dataLayer','GTM-MyID');</script>
       <em><!-- End Google Tag Manager --></em>
       ... some <body> code here...
       ```
   
 * I have 3 questions:
 * 1) Is it OK that I have any code related to the plugin in the <head> where I 
   only called the pulgin’s function after body?
 * 2) Is it OK that I have this kind of code like shown in (NO.#2) where part of
   the block (according to your comments) is in the <head> and the rest is in the
   <body>?
 * 3) Is it natural that the comment block of code the plugin inserts surrounds 
   other elements/scripts loaded in the page? (NO.#1)?
 * Thank you!!
 * [https://wordpress.org/plugins/duracelltomi-google-tag-manager/](https://wordpress.org/plugins/duracelltomi-google-tag-manager/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * (@duracelltomi)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/general-technical-question/#post-7435403)
 * Hi,
 * 1) yes, that is normal, in the <head> section I define the so called data layer
   variables that needs to be accessible while your tags firing on “All pages” trigger.
 * 2) Yes, the code at the beginning of the <body> loads your published GTM container
   and starts to fire your tags on “All pages”
 * 3) No, that is an odd behavior and it might be caused by some cache plugins
 * Thomas

Viewing 1 replies (of 1 total)

The topic ‘General technical question’ is closed to new replies.

 * ![](https://ps.w.org/duracelltomi-google-tag-manager/assets/icon-256x256.png?
   rev=1708451)
 * [GTM4WP - A Google Tag Manager (GTM) plugin for WordPress](https://wordpress.org/plugins/duracelltomi-google-tag-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duracelltomi-google-tag-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/general-technical-question/#post-7435403)
 * Status: not resolved