Faced the same issue today. We did not want to use the extension so we used the method below.
Google recommends putting the tag manager right after the opening tag. From your code it seems like you are adding the tag to the page instead.
To add it to the body of your page go to your main template file and a market using "###MARKERNAME###".
e.g.
<div id="container" class="home">
<div id="google-tagmanager">
###TAGMAN###
</div>
Then go to Template > Templates > Main page template (PAGE) > Setup. Add the marker and its injected value to the page object
marks.TAGMAN = TEXT
marks.TAGMAN =< lib.gtmContainer
Finally, add lib.gtmContainer to your Standard Page Parts (LIB).
lib.gtmContainer = TEXT
lib.gtmContainer.value (
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" 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-XXXXX');</script>
)
This seemed to work well for us. Hope it helps!