Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #987821
    Alex
    Participant

    Hello,

    I want to put my Google Tag Manager code instead of Google Analytics code. I know I need to strip the code off something for it to work properly, but I don’t remember what I should remove.

    Here’s my GA code:

    `(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

    ga(‘create’, ‘UA-69481740-1’, ‘auto’);
    ga(‘send’, ‘pageview’);`

    And here’s the new GTM code I need to set up:

    <!-- Google Tag Manager -->
    <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-TC8DXX"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <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=
    '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-TC8DXX');</script>
    <!-- End Google Tag Manager -->

    Can you tell me please how I must put it into the Customizer?

    Thanks.


    Alex

    #988148
    Joao
    Moderator

    Hi Alex,

    We have Google Analytics Addon that is made specially for you to put your code in.

    Please install it and you will find the place there to paste your code.

    You can find the GA Addons at your W-Admin Dashboabord / Adoonds / Home

    Hope that helps,

    Joao

    #989419
    Alex
    Participant

    Hello,

    Thank you! But can I add Google Tag Manager code into the addon?


    Alex

    #989442
    Christopher
    Moderator

    Hi there,

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Please add following code in child theme’s functions.php file :

    // Add Google Tag Manager Code
    // =============================================================================
    function add_google_tag_manager_code(){
    ?>
    
    <!-- Google Tag Code starts here  -->
    
    place the google tag manager code here
    
    <!-- Google Tag Code ends here -->
    
    <?php 
    }
    add_action( 'wp_head', 'add_google_tag_manager_code' );
    // End Add Google Tag Manager Code
    // =============================================================================
    

    Hope it helps.

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