After we receive our code. We remind you, there should be 2 parts – 1 must be placed in the head and the other after the opening bodytag.
Well, let’s start. Let’s go to the admin panel of our site and open the function.php file of our active theme. Add to this file:
add_action('wp_head', 'lube_header'); function lube_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-KTT1111'); </script> <!-- End Google Tag Manager --> <?php };
add_action('wp_body_open', 'lube_body_top'); function lube_body_top() { ?> <!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KTT1111" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) --> <?php };