Skip to main content
justbobm202
Participating Frequently
November 28, 2018
Answered

how to impliment gtags in Dreamweaver CS6 version 12

  • November 28, 2018
  • 2 replies
  • 1547 views

Where does the gtag code go, just in the index or in each template

    This topic has been closed for replies.
    Correct answer WolfShade

    Are you using a header template (ie, a page that is included on every page for the top of your site)?  If you have a template that is included on every page, it only needs to go into the header template.

    If you are NOT using a header template, then it goes on every page.

    In both cases, the code goes immediately after the <head> tag.

    HTH,

    ^ _ ^

    2 replies

    anissa_thompson
    Community Expert
    Community Expert
    November 28, 2018

    The official answer from Google Developers (Add gtag.js to your site  |  Analytics for Web (gtag.js)  |  Google Developers)

    Install the global tracking snippet

    To install the global tracking snippet, copy the following code and paste it immediately after the <head> tag on every page of your site. Replace GA_TRACKING_ID with the tracking ID of the Google Analytics property to which you want to send data. You need only one global snippet per page.

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
    <script>
      window
    .dataLayer = window.dataLayer || [];
     
    function gtag(){dataLayer.push(arguments);}
      gtag
    ('js', new Date());

      gtag
    ('config', 'GA_TRACKING_ID');
    </script>

    This snippet loads the gtag.js library, establishes GA_TRACKING_ID as the default Google Analytics property ID, and sends a pageview hit to Google Analytics.

    If you'd like an easier way to track any Google and other 3rd party Javascript plugin and tracking codes, I highly recommend using Google Tag Manager (https://tagmanager.google.com) along with both the Google Page Analytics (1) and Google Tag Assistant (2) Extensions for Chrome. All three together will make tagging and tracking much easier to handle.

    Hope this helps! Make sure to press "✔ Correct Answer" on this post if this answers your question. Happy Creating!Anissa • @anissat
    WolfShade
    Legend
    November 28, 2018

    Personally, I find tracking evil.  But..

    According to https://developers.google.com/analytics/devguides/collection/gtagjs/, you place the code after the <head> tag.  If you are not using a header file, then it goes on every page.  If you are using a header file, then it goes just in the header.

    HTH,

    ^ _ ^

    justbobm202
    Participating Frequently
    November 28, 2018

    hi, so are you saying it only needs to go in the header of the one index page? If so does that one tag do the whole site?

    WolfShade
    WolfShadeCorrect answer
    Legend
    November 28, 2018

    Are you using a header template (ie, a page that is included on every page for the top of your site)?  If you have a template that is included on every page, it only needs to go into the header template.

    If you are NOT using a header template, then it goes on every page.

    In both cases, the code goes immediately after the <head> tag.

    HTH,

    ^ _ ^