[Support request] Web hooks for Google Tag Manager

Home Forums Support [Support request] Web hooks for Google Tag Manager

Home Forums Support Web hooks for Google Tag Manager

  • This topic has 1 reply, 2 voices, and was last updated 5 years ago by David.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #854439
    Evan

    Hello again –

    Quick question for you guys. I’m currently adding Google Tag Manager code to my site, and I need to add two snippets of code – one in the <head> of every page, and one immediately after the opening <body> tag.

    I’m pretty sure I can use webhooks to add the code into the <head> of every page by using wp_head on every page with a position of 2 (so it’s below my GA tag). However, I’m not quite sure how to use a webhook to add the second bit of code right after the opening <body> tag. Is it possible to do this with a webhook?

    Also, I’m assuming I need to put the Google Tag Manager code in the <head> below my GA tag for Google Analytics?

    Thanks as always! I’ve included the two snippets of code below for reference.

    – Evan

    Paste this code as high in the <head> of the page as possible on every page:

    <!– 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-NJHHGGJ’);</script>
    <!– End Google Tag Manager –>

    Additionally, paste this code immediately after the opening <body> tag:

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

    #854452
    David
    Staff
    Customer Support

    Hi there,

    the before_header hook with the priority set to zero will place the second tag after the opening body tag.

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