Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1395254
    Mauricio
    Participant

    Hi,

    I’m trying to install GTM tag in the child’s theme functions.php, its seems that is correct but the tag assistant doesnt recognize it.

    ¿Can you see any mistake?

    /*THIS CODE WILL BE OUTPUT INSIDE THE <HEAD> tag*/
    add_action(‘wp_head’,’my_tracking’, 1);
    function my_tracking () { ?>
    <!– Google Tag Manager –>

    <!– 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-MGRR545′);</script>
    <!– End Google Tag Manager –>

    <!– End Google Tag Manager –>
    <?php }

    // Add Google Tag Manager Code
    // =============================================================================
    function add_google_tag_manager_code(){
    ?>

    <!– Insert Google Tag Code starts here –>

    <!– Google Tag Manager (noscript) –>
    <noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-MGRR545&#8243;
    height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
    <!– End Google Tag Manager (noscript) –>

    <!– Insert Google Tag Code ends here –>

    <?php
    }
    add_action( ‘x_before_site_begin’, ‘add_google_tag_manager_code’ );
    // End Add Google Tag Manager Code
    // =============================================================================

    Thanks a lot!!

    #1395630
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! I guess this is a duplicate post.

    Assuming you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file.

    // THIS CODE WILL BE OUTPUT INSIDE THE <HEAD> tag
    // =============================================================================
    add_action('wp_head','my_tracking', 1);
    function my_tracking () { ?>
    	<!– Google Tag Manager –>
    
    	<!– 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',");</script>
    	<!– End Google Tag Manager –>
    
    	<!– End Google Tag Manager –>
    <?php }
    
    // Add Google Tag Manager Code
    // =============================================================================
    function add_google_tag_manager_code(){
    ?>
    
    	<!– Insert Google Tag Code starts here –>
    
    	<!– Google Tag Manager (noscript) –>
    	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MGRR545"
    	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    	<!– End Google Tag Manager (noscript) –>
    
    	<!– Insert Google Tag Code ends here –>
    
    <?php
    }
    add_action( 'x_before_site_begin', 'add_google_tag_manager_code' );
    // End Add Google Tag Manager Code
    // =============================================================================

    Hope this helps.

  • <script> jQuery(function($){ $("#no-reply-1395254 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>