title: How do I prevent Google Tag Manager from appending javascript after html
body: <p>I recently began working on a client's site that has Google Tag Manager running on it. The following code was used to implement GTM:</p>
  
  <pre><code>&lt;noscript&gt;&lt;iframe src='//www.googletagmanager.com/ns.html?id=GTM-PFTF46'
  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-PFTF46');&lt;/script&gt;
  </code></pre>
  
  <p>It appears to be tracking fine, but it's appending the following code to the bottom of the page after the content:</p>
  
  <pre><code>if (document.referrer.match(/google\.com/gi) &amp;&amp; document.referrer.match(/cd/gi)) { var myString = document.referrer; var r = myString.match(/cd=(.*?)&amp;/); var rank = parseInt(r[1]); var kw = myString.match(/q=(.*?)&amp;/); if (kw[1].length &gt; 0) { var keyWord = decodeURI(kw[1]); } else { keyWord = "(not provided)"; } var p = document.location.pathname; _gaq.push(['_trackEvent', 'RankTracker', keyWord, p, rank, true]); }
  </code></pre>
  
  <p>See the <a href="http://i.stack.imgur.com/68b8Z.png" rel="nofollow">screenshot</a> for a better understanding. When I removed the GTM tracking code, this Javascript was not appended to the bottom of the page, so I have at least isolated that GTM is adding it. </p>
  
  <p>Does anyone know how I can fix this? Thank you.</p>
  
  <p>The website in question is <a href="http://www.fleischersport.com" rel="nofollow">http://www.fleischersport.com</a></p>