Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1356063
    Michael R
    Participant

    Hello,
    I need to place a tracking code on my site but the code cannot be placed within the <head> </head> tags of the page.

    I found another question similar to mine about adding a tracking code to the theme’s footer.php file.

    The answer given was to add the code below to the functions.php file:

    add_action(‘wp_footer’, ‘my_tracking_code’, 9999);

    function my_tracking_code() { ?>

    <!–replace this line with your tracking code–>

    <?php }

    However, when I create a page using the template “No Container – No Header, No Footer” this code does not populate. How can I add the tracking code to all pages so that it will appear even if I use a template with No Footer, No Header without putting it in the <head> tags?

    Thank you.

    #1356069
    Michael R
    Participant
    This reply has been marked as private.
    #1356350
    Rupok
    Member

    Hi there,

    Thanks for writing in! You can follow this thread to add code to footer – https://community.theme.co/forums/topic/need-to-add-google-number-script-to-the-footer/#post-908572

    And this to use within header – https://community.theme.co/forums/topic/add-tracking-code-to-header/#post-776299

    Cheers!

    #1357058
    Michael R
    Participant
    This reply has been marked as private.
    #1357545
    Friech
    Moderator

    Hi There,

    It does not really matter what page template you’re using, as long as your template follows the standard structure of an HTML document. That given code will always output immediately before the </body> tag.

    add_action('wp_footer', 'my_custom_footer_script', 9999);
    
    function my_custom_footer_script() { ?>
    
    <!-- TraCKING CODE HERE -->
    
    <?php }

    Maybe it was your caching did not re-generate, the first time you test this code on a No footer template. Make sure to always clear your caching plugin and your browser’s cache.

    Thanks.

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