Exclude GTM code from AMP
-
Hi,
How can I exclude GTM code from AMP.
I don’t want to load GTM code in AMP.
This is the code/* Google Tag Manager START */ add_action( 'wp_head','add_gtm_script_part' ); function add_gtm_script_part () { ?> <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-543DQCK');</script> <?php } add_action( 'astra_body_top','add_gtm_noscript_part' ); function add_gtm_noscript_part () { ?> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-543DQCK" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <?php } /* Google Tag Manager END */
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Exclude GTM code from AMP’ is closed to new replies.