Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Support request] Where to place gtag code

Home Forums Support Where to place gtag code

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #465888
    Louie

    I just got a google analytics account and was give the following code below. A couple of questions please:
    1. I do not see <HEAD> on any of the pages. Am I missing something?
    2. Is there an easier way to use this code? Header? Footer? Widget? CSS?
    3. Do I have a Global Site Tag

    Thanks.

    Global Site Tag (gtag.js)
    This is the Global Site Tag (gtag.js) tracking code for this property. Copy and paste this code as the first item into the <HEAD> of every web page that you want to track. If you already have a Global Site Tag on your page, simply add the config line from the snippet below to your existing Global Site Tag.

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-112123355-1″></script&gt;
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘UA-112123355-1’);
    </script>

    GeneratePress 2.0.1
    GP Premium 1.5.6
    #465995
    Leo
    Staff
    Customer Support
    #466196
    Louie

    Thank you. I found it. Should I replace this one?:
    <!– 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-538XZ3Q’);</script>
    <!– End Google Tag Manager –>

    With this one from Google?:

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-112123355-1″></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘UA-112123355-1’);
    </script>

    #466200
    Leo
    Staff
    Customer Support
    #466690
    Louie

    This is the response I received from someone at stackexchage – Lines have been deleted. what do you think?:

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

    From my Google Analytics account:

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=UA-112123355-1″></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘UA-112123355-1’);
    </script>

    #466710
    Leo
    Staff
    Customer Support

    I’m not sure what you mean?

    Google should’ve provided the specific instruction along with the code.

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