[Support request] Google Tag Manager related isshu

Home Forums Support Google Tag Manager related isshu

  • This topic has 22 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #1200135
    Ajay

    hey, I’m unable to see a Google Tag Manager head code on my site. the body tag is visible but the head tag isn’t watchable. head tag applied hook is wp_head and the proxy is 10 with all pages. how can I see my code?

    #1200217
    David
    Staff
    Customer Support

    Hi there,

    i can see the HTML comments for the Tag in the WP_head ie.

    <!-- Google Tag Manager -->
    <!-- End Google Tag Manager -->

    If the comments are part of your code it says the hook is working.

    The missing script says that maybe the code has an error in there.

    Can you copy and paste the exact code you have here. Make sure you highlight the code and click the Code button before submitting.

    #1200255
    Ajay

    sorry but I didn’t get it what do you wanna say but I did copy and past again in and the issue is not sorted out until now. please help?

    #1200268
    David
    Staff
    Customer Support

    Copy the code you have in your site. And paste it here in this forum.

    #1200280
    Ajay

    look:

    <!-- 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-NW4WCSB');</script>
    <!-- End Google Tag Manager -->
    #1200287
    David
    Staff
    Customer Support
    #1200315
    Ajay

    why I cannot put code via hook? also, I’m using autopimize plugin that might be causing the problem? any solution add code without using any plugin?

    #1200320
    David
    Staff
    Customer Support

    The Hook Element writes the code to the Database.
    Some Hosts will not allow <script> tags to be written to the database. You can check this with your Host.

    The functions method i provided does not require plugins.

    #1200326
    Ajay

    so i can simply put the code into the head and body section? in theme editor? but if someday the theme update would come in the future then my code will be there whether yes or not? please guide me step by step how to do that?

    #1200363
    Ajay

    what should I do I’m so confused?

    #1200374
    David
    Staff
    Customer Support

    This is the code – simply add your scripts in place of <!-- Add your code --> :

    <?php
    add_action( 'wp_head','gtm_part_1' );  
    function gtm_part_1() { ?> 
        <!-- Google Tag Manager -->
    
            <!-- Add your code -->
    
        <!-- End Google Tag Manager -->
    <?php }
    
    add_action( 'wp_body_open','gtm_part_2',0 );  
    function gtm_part_2() { ?> 
        <!-- Google Tag Manager (noscript) -->
    
            <!-- Add your code -->
    
        <!-- End Google Tag Manager (noscript) -->
    <?php }

    Then you have two choices to add these codes:

    1. Install the Code Snippets plugin:
    https://en-gb.wordpress.org/plugins/code-snippets/

    2. Install a Child Theme.
    Link to child theme here:
    http://generatepress.com/api/themes/generatepress_child.zip

    Then edit the Child Theme Functions.php and add the codes

    #1200387
    Ajay

    I got the reason why it was happening. As my investigation, the autoptimize plugin was causing the problem. otherwise, I could be able to see my code. I think code is working properly but autoptimize has been hidden the code. isn’t it right? there is no need to do anything. what is your thought about it?

    #1200394
    David
    Staff
    Customer Support

    If you can disable Autoptimize i can take a look.

    #1201210
    Ajay

    ok now I do let’s check that

    #1201621
    David
    Staff
    Customer Support

    Yep – i can see GTM Script in the <head>.
    What are the JS settings you have used in Autoptimize ? Can you share a screenshot ?

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.