Discord Chat Commands
Technology

How To Insert The Tracking Code On Every Page Of Your Site?

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) Tracking Code

<!– 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).

Universal Tag (analytics.js) Tracking code

<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.

  1. Copy the tracking code into a new document in a text editor
  2. Remove <script> and </ script> tags from your tracking code
  3. Save the file with the same extension as “.js” and the same encoding method as the HTML file of the site.
  4. Upload 3 files to a suitable directory on your webserver
  5. Write the following line in the <head> ~ </ head> tags of the HTML source code of all pages.

Also Read : How To Register A Website In Google Search Console

Admin Team

Tech Today Post is an online international journal for all the latest technology news & updates. We also write about Digital Marketing, Business, Software and Gadgets.

Recent Posts

ZO35-G25DA74 Model TV – Specs, Price, Review, Installation & More

If you're looking for a smart TV that suits your budget and performs well, the…

1 week ago

Cybersecurity Awareness – Stay Safe Online with Simple Tips

internet every day - for work, for shopping, for banking, and school. Unfortunately, dangers online…

2 weeks ago

A Beginner’s Guide To Business Management

Launching a business is exciting. However, managing it can be unclear. Here's where the Business…

3 weeks ago

FamiGuard Review: Advanced Parental Monitoring Features Tested and Explained

Parents today must subscribe to a parental control solution to help monitor their children’s online…

1 month ago

Betting on the Future: How AI is Lengthening the $250B Sports Betting Industry

On any given night in Las Vegas, any sportsbook is abuzz. Flickering dozens of TVs…

1 month ago

What Are Altcoins and How Do They Differ From Bitcoin?

While Bitcoin, the world’s first cryptocurrency, is considered the undisputed leader, cryptocurrencies other than Bitcoin…

2 months ago