Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1140560
    AliASSK
    Participant

    Hi,

    I want to use GTM on my site, but I cant find out how.

    1 – I download plugin fort GTM > Insert my GTM ID > And choose ” Custom (needs tweak in your template)”

    After choosing “Custom” I had to do this – “If you select ‘Custom’ you need to edit your template file and add the following line just after the opening <body> tag:”

    I was lookin for tutorials, I found out i need to edit header.php but there is no <body> part in Theme X.
    I also try to do this directly through FTP but also no luck.

    Can you help find right folder for puting this line of code right after opening <body> tag? <?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>

    #1140710
    Rad
    Moderator

    Hi there,

    Thanks for writing in.

    There is no need to directly edit the templates, WordPress has wp_head and wp_footer for that main reason. But instead, we will use X hooks. Please add this code to your child theme’s functions.php

    //After <body>
    
    add_action('x_before_site_begin', 'place_this_after_body', 99 );
    
    function place_this_after_body () { 
    
     if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); }
    
    }

    X theme has header.php, but they are separated as template parts and located on view folder.

    Thanks!

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