Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1300889
    cmdev
    Participant

    I have installed X child theme, need to insert the following tag in the <body> of the site.

    triflight.com

    <!– Tracking tag. Place in the <body> section of webpage –>
    <!– Privacy policy at http://tag.brandcdn.com/privacy –>
    <script type=”text/javascript” src=”//tag.brandcdn.com/autoscript/tricitiesairport_vfhwtk5fmvvaeja9/TriCitiesAirport.js”></script>

    #1301021
    Friech
    Moderator

    Hi There,

    Thanks for writing in! Please add the code below on your child theme’s functions.php file.

    add_action( 'x_before_site_begin', 'tracking_tag' );
    function tracking_tag() {  ?>
      
    <!-- Tracking tag. Place in the <body> section of webpage
    Privacy policy at http://tag.brandcdn.com/privacy -->
    <script type="text/javascript" src="//tag.brandcdn.com/autoscript/tricitiesairport_vfhwtk5fmvvaeja9/TriCitiesAirport.js"></script>
    
      <?php
    }

    Hope it helps, Cheers!

    #1302043
    cmdev
    Participant
    This reply has been marked as private.
    #1302352
    Darshana
    Moderator

    Hi there,

    To add it on the header section, please refer to the following example.

    add_action('wp_head','my_tracking_pixel');
    function my_tracking_pixel() { ?>
    
    <!-- Add Your Tracking Pixel Here -->
    
    <?php
    }

    Hope that helps.

    #1303949
    cmdev
    Participant

    How about adding to the opening <body> tag?

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

    #1303974
    Thai
    Moderator

    Here you are:

    add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
    function print_script_before_site_begin(){
    	?>
    	<!-- Google Tag Manager (noscript) -->
    	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KR2PX7H"
    	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    	<!-- End Google Tag Manager (noscript) -->
    	<?php
    }

    Regards!

    #1305258
    cmdev
    Participant

    Help, I added this and now my website is down!

    #1305264
    cmdev
    Participant

    How can i change my site back to the X theme without the child theme?

    #1305300
    Friech
    Moderator

    Hi There,

    You can easy remove or update the erroneous code with an FTP. Please provide us FTP credentials so we can take a look on the functions.php file.

    We do not advice removing the child theme because it is necessary if you have customisation.

    Thanks.

    #1305303
    cmdev
    Participant

    I replaced the child theme with a fresh install of the child theme via FTP.
    I have only been using it for the tags.

    Can you see what was the error?

    #1305305
    cmdev
    Participant

    Screen shot attached.
    Error added at top of screen when the edits are made to the function.php file.

    #1305316
    Lely
    Moderator

    Hello There,

    Thank you for the screenshot. There is syntax error on the functions.php file. If you do not have any other code, your child theme’s functions.php file should look like this:

    
    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
    function print_script_before_site_begin(){
    	?>
    	<!-- Google Tag Manager (noscript) -->
    	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KR2PX7H"
    	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    	<!-- End Google Tag Manager (noscript) -->
    	<?php
    }

    Hope this helps.

    #1305319
    cmdev
    Participant
    This reply has been marked as private.
    #1305334
    Lely
    Moderator

    Hello There,

    It should be something like this:

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
    function print_script_before_site_begin(){
    	?>
    	<!-- Google Tag Manager (noscript) -->
    	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KR2PX7H"
    	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    	<!-- End Google Tag Manager (noscript) -->
    	
    	<!-- Tracking tag. Place in the <body> section of webpage Privacy policy at http://tag.brandcdn.com/privacy -->
    	<script type="text/javascript" src="//tag.brandcdn.com/autoscript/tricitiesairport_vfhwtk5fmvvaeja9/TriCitiesAirport.js"></script>
    	<?php
    }
    
    function third_party_tracking_code() { ?>
    
    <!-- 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-KR2PX7H'); </script>
    <!-- End Google Tag Manager -->
    
    <?php }
    
    add_action( 'wp_head', 'third_party_tracking_code' );

    Check if the last google tag manager is correct.

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