Google Tag Manager Positioning

I have a general question regarding the positioning of a google tag manager snippet. According to the google implementation guide, the tag manager should be implemented immediately after the body tag is launched. My question is this:

  • What happens with tracking scripts that need to be loaded into the head?
  • What happens with tracking scripts that need to be loaded at the end of the body?

For example, VWO (visual website optimizer) recommends loading code into the head to avoid flickering ...

Can I have 2 containers? one at the end of the head and one at the beginning of the body?

+4
source share
2 answers

, , ( ). , GTM , , , GTM DOM- . javascript, . GTM , ( javascript, iframe). , GTM , DOM, javascript, , ( , ).

Google , , (, A/B-Testing Tools, " " , GTM ) .

+2

, GTM A/B, Google Optimize.

, : <header>:

    <!-- Google Tag Manager -->
<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-CONTAINER_ID');</script>
<!-- End Google Tag Manager -->

<body>

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-CONTAINTER_ID"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
0

Source: https://habr.com/ru/post/1545196/


All Articles