title: Google Tag Manager (GTM) not working on SharePoint
body: <p>I added the GTM code inside the SharePoint Master Page inside the body tag. </p>
  
  <pre><code>&lt;body&gt;
  &lt;--Body content goes here --&gt;
  
  &lt;!-- Google Tag Manager --&gt;
          &lt;noscript&gt;&lt;iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
          height="0" width="0" style="display:none;visibility:hidden"&gt;&lt;/iframe&gt;&lt;/noscript&gt;
          &lt;script&gt;(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'?'&amp;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-T9XLSX');&lt;/script&gt;
          &lt;!-- End Google Tag Manager --&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>But It seems that the script is not properly fired as the whole content is wrapped by a form element as following.It generate by SharePoint.  </p>
  
  <pre><code>&lt;body&gt;
      &lt;form method="post" action="" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm"&gt;
      &lt;--Body content goes here --&gt;
  
      &lt;!-- Google Tag Manager --&gt;
              &lt;noscript&gt;&lt;iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
              height="0" width="0" style="display:none;visibility:hidden"&gt;&lt;/iframe&gt;&lt;/noscript&gt;
              &lt;script&gt;(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'?'&amp;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-T9XLSX');&lt;/script&gt;
              &lt;!-- End Google Tag Manager --&gt;
     &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Is there a way we can properly place the tag in SharePoint?</p>