Lightweight Google Analytics Tracking Code to Increase Website Speed

0 Comments
Editor Ratings:
User Ratings:
[Total: 0 Average: 0]




This post aims to explain how to minify Google Analytics tracking code to increase website speedMinimal Google Analytics Snippet is a replacement of the traditional Google tracking code that you add to your website. Here this script has removed Google Tag Manager and Analytics libraries from the main script thus it helps you decrease the page load time.

This script has been optimized for sending the page views data to Analytics API without sending the tracking information of users to the Google servers. However, if you want to use Adwords tracking on your website pages then it will not work for you. In that case, you will have to use the original Analytics tracking code that Google gives you.

If you want to save bandwidth and improve site speed then you should minimize JavaScript code on your website. In website ranking parameters, website speed counts and even 1 second helps. And you can easily do that if you minify the Google Analytics tracking script on the web page. The original tracking code has a size approximately 80 KB and if you use the script that I have mentioned here, you can can reduce it to just ~2KB.

Google Analytics Tracking Code to Improve Website Speed

Lightweight Google Analytics Tracking Code to Increase Website Speed:

This optimized Google Analytics tracking code is openly available on GitHub. And in later updates there will be some more options will be included like anonymizing IP addresses.

Just copy the script code from here and then simply paste it the <head></head> section of the website. You just have to add your tracking ID in it in place of “XX-XXXXXXXXX-X”. If you don’t know your tracking ID then log in Google Analytics with your Google account and from the Admin > Tracking Info section, you can copy the tracking ID and add to the script.

Minimal Google Analytics Snippet Google Analytics

Now, after adding the script leave it and let its do its work. You will soon start receiving the page views information in the Google Analytics reports. If you want to see the before and after results of the website performance then you can see this Pingdom report for my test demo website where I used this script. The difference in load time is not that big but still it is very good.

Google Analytics script comparison after minifying

In this way, you can use easily use this lightweight Google Analytics tracking code to increase websites speed. And the best part is that you literally have to do nothing difficult. You just have to replace the old Google Analytics code with the whose link I have given above.

Final thoughts

Minimal Google Analytics Snippet is a simple script that you can easily use in place of the original script that Google Analytics gives you. You can easily add it on your websites and start getting the page view details right in reporting section of Google Analytics. If you are looking for ways to increase site speed then you can try modifying Google Analytics tracking code and this post will show you how.

Editor Ratings:
User Ratings:
[Total: 0 Average: 0]
Free/Paid: Free

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer