This post aims to explain how to minify Google Analytics tracking code to increase website speed. Minimal 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.
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.
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.
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.
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.