The tracking code displayed after opening an account is a character string of about 10 lines written in a programming language called “JavaScript” and is also called a “tag”. This tag inserts on all pages of the site to be analyzed; this completes the introduction of Google Analytics.
<!– Global site tag (gtag.js) – Google Analytics –>
<script async=”” src=”https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-Y”></script>
<script><font></font>
window.dataLayer = window.dataLayer || [];<font></font>
function gtag(){dataLayer.push(arguments);}<font></font>
gtag(‘js’, new Date());<font></font>
<font></font>
gtag(‘config’, ‘UA-XXXXXXXXX-Y’);<font></font>
</script>
The part starting with “UA-” is the tracking code. Also known as a “web property ID”. 8: The most important line for various settings of Google Analytics. This line is also responsible for sending page views.
The above tags are called ” Global Site Tags ” of Google Analytics, commonly known as ” gtag.js “, and appeared in beta in August 2017. It became the official version in October 2017, and the insertion location is recommended immediately after the <head> tag (start tag of the head element) of the HTML source.
However, when introducing Google Analytics, inserting tracking code via Google Tag Manager has become almost the de-facto standard. Google Tag Manager has several advantages such as the easy acquisition of data in web analytics.
On the other hand, gtag.js is not recommended to be used via Google Tag Manager, so there is an image that is not widely used. Since there is no data that can only be acquired with gtag.js, there is no reason to actively use it.
Therefore, The most recommended way to implement Google Analytics is to insert the traditional ” universal tag “, commonly known as ” analytics.js “, into every page of the site via Google Tag Manager.
Also, this book is intended not only for those who are going to introduce Google Analytics, but also for those who have already introduced it, but I think that most of the latter are using analytics.js. The instructions in this document also assume that you are deploying Google Analytics via Google Tag Manager, or that you are inserting analytics.js tags directly into your HTML source.
When inserting the tag of analytics.js directly, get the tag from the official help and rewrite the tracking ID as shown below. The recommended insertion location is just before the HTML source tag (end tag of the head element).
<script><font></font>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){<font></font>
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),<font></font>
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)<font></font>
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);<font></font>
<font></font>
ga(‘create’, ‘UA-XXXXXXXXX-Y’, ‘auto’);<font></font>
ga(‘send’, ‘pageview’);<font></font>
</script>
The part starting with “UA-” is the tracking ID. Rewrite to the property of your own site. 8: send command. Send the pageview of the tagged page to Google Analytics.
Add analytics.js to your site
You can paste the tracking code into the HTML source of the page as it is, but it is also effective to put it in one file as an external file and write JavaScript to read that file in HTML. If you need to change your tracking code, you can modify one file to cover all pages. The method is as follows.
Also Read : How To Register A Website In Google Search Console
All employees need to follow a smart approach to manage their work hours because it…
The movement of goods under procurement requires shipping to operate as a fundamental step that…
The networking and internet domain depends on IP addresses, although numerous users find these numbers…
Introduction It has been a long time since, Vivo is a well-known company in the field…
The tech industry stands as a powerful cog in the machinery of global progress. Companies…
Modern display technology has changed the way we view visuals by offering breathtaking resolution and…