[Resolved] Google Manager Tag

Home Forums Support [Resolved] Google Manager Tag

Home Forums Support Google Manager Tag

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #51019
    Randolph Philp

    Good morning,

    Yesterday I tried for several hours to use a plugin, but I don’t think I did it correctly. I installed and activated the following:

    DuracellTomi’s Google Tag Manager for WordPress

    In his installation instruction, the plugin developer wrote the following of code:

    <?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>

    after the body tag in order to keep Google Tag Manager from showing at the footer. I did so, but it did not seem to work.

    I checked my Google Analytics Account and says that tracking is not installed. Here is a copy of how I added the snippet to the header template:

    <body itemtype=”http://schema.org/WebPage&#8221; itemscope=”itemscope” <?php body_class(); ?>>
    <?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>
    <?php do_action( ‘generate_before_header’ ); ?>
    <header itemtype=”http://schema.org/WPHeader&#8221; itemscope=”itemscope” id=”masthead” role=”banner” <?php generate_header_class(); ?>>

    Did I do this correctly? Was that the correct body tag? I am rather new at using html and css. Could you please be detailed in your response?

    Thank you very much!

    Randy

    #51053
    Tom
    Lead Developer
    Lead Developer

    Hi Randy,

    First – I wouldn’t edit any of the core files as those edits will be removed if you decide to update to a newer version.

    This would be much easier if you happen to have GP Hooks, as it would allow you to hook this code into your website without touching any core files.

    As for the functionality of the code – I’m afraid I’m not much help as I’ve never used it. You’ll have to ask the developer why it’s not working for you.

    Let me know πŸ™‚

    #51069
    Randolph Philp

    Thank you for the prompt response Tom. I left a question in the plugin developer’s forum. It makes sense to use the hooks. Thank you for pointing that out.

    Which hook should I use if the plugin developer wrote that his code should be placed after the body tag?

    I also called Google Analytics. They said it can take 24 to 48 hours for Google Analytics to be able to see the tracking code on my website. Maybe the plugin works, but I just have to wait and see…

    Thanks again,
    Randy πŸ™‚

    #51090
    Tom
    Lead Developer
    Lead Developer

    It depends.. Usually Google Analytics code is placed in the “wp_head” hook.

    However, I’m not sure what this plugin is doing exactly, so it’s hard to tell.

    It will be in wp_head or wp_footer.

    Also, be sure to check “Execute PHP” in the hook in order for the PHP to be read.

    #51092
    Randolph Philp

    Excellent! I will give it a shot. Thanks again Tom!

    #51210
    Randolph Philp

    Hi Tom,

    Thanks again for the great advise! I didn’t even need the plugin I referred to earlier!!!

    I deleted the plugin and pasted the google tag manager code into the footer hook. It worked like a charm. Also, my google analytics is now tracking (as directed by the tag manager)

    I just had to wait about 24 hours for google analytics to “find” my code and now I can see my stats.

    I hope this helps someone else! Awesome theme!

    Randy

    #51221
    Tom
    Lead Developer
    Lead Developer

    Happy I could help πŸ™‚

    #183052
    Ryan

    I actually think it’s best to put the GTM code in the “Before Header” section so that the browser reads it immediately after the body tag.

    #183070
    Tom
    Lead Developer
    Lead Developer

    Good point! Just looked it up and that’s where it should go πŸ™‚

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