Google Analytics Integration

Google Analytics also a part of your SEO measurements. Of course it is not necessary, but it may give you feedbacks regarding your traffic and visits.

shape
shape
shape
shape
shape
shape
shape
shape
Google Analytics Integration

Google Analytics Integration

You need to upload the codes obtained by Google Analytics to the heading area of the page. The code structure is as follows;

<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-5"></script>

<script>

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

 

  gtag('config', 'UA-XXXXXXXXX-X');

</script>


You can get this code by directly follow the directions of Google Analytics. Please remember that this code is a general structure for Google Universal Analytics. There is a different code structure for Google Analytics v4. But the replacement of the code is always the same and you should put the code exactly to the same place.

Please make sure that you have already replaced your Google Analytics ID instead XXXXXXXXX things here. 

The place you should replace the code is inside of <head> tag. We prefer you to insert your code to the end of <head> tag as below;

    …

    …

    …

 

    <script async=""       src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-5"></script>

    <script>

        window.dataLayer = window.dataLayer || [];

        function gtag(){dataLayer.push(arguments);}

        gtag('js', new Date());

 

        gtag('config', 'UA-XXXXXXXXX-5');

    </script>

 </head>


In order to check whether it has been added correctly, you can install Google Tag Assistant that is a Google Chrome extension created by Google. Google Tag Assistant is located in the Chrome Web Store and you can easily find it by searching it's name on Google or Google Web Store.

Please be sure that you enabled your Google Tag Assistant and refreshed the page once it is enabled to determine if you have inserted the code correctly.

Google Tag Assistant is not only exists to check if you insert Google Analytics Code correctly. It can also determine some other third party code structures and catches event based things happen on your website. This will be discussed in a different article.

Write a comment