How to Host Google Analytics Locally in WordPress?

Share your love by sharing

A fast-loading website is crucial when it comes to ranking and SEO improvement. We do a lot to optimize our website or blog for performance. We spend a lot of money on hosting, performance tools, and themes.

How-to-Host-Google-Analytics-Locally-in-WordPress
How-to-Host-Google-Analytics-Locally-in-WordPress

The javascript kills the Pagespeed score and most of the javascript comes from the Google Analytics code that is added to our website or blog. If you research a bit, you will find that nearly 45% of the total script is javascript. Today in this guide we will learn how to host Google Analytics locally in WordPress.

Why host Google Analytics Locally?

The benefit of hosting Google Analytics locally is it doesn’t ping Google servers to share data every time a user visits your website. It captures all the data on its own and forwards it to Google once in a while.

Advantages of hosting Google Analytics locally

  1. It fixes leverage browser caching errors
  2. Reduce the number of requests
  3. Improve GTmetrix, Pingdom, and PageSpeed insights score
  4. Reduce DNS lookup

Disadvantages of hosting Google Analytics locally

  1. Minimal Analytics version (GA4) collects info only about the visits and demographics
  2. If you have a Woocommerce website, it might create issues

How to Host Google Analytics Locally in WordPress?

To host Google Analytics locally, we will use CAOS WordPress plugin that Daan has developed, the same developer who developed the OMGF plugin that hosts Google Fonts locally.

Step 1 – Install CAOS WordPress plugin

CAOS is my favorite plugin. I am using it on most of the websites. It offers a complete optimization solution for analytics for WordPress

Go to “Plugins“, then click on “Add New Plugin

install-CAOS-plugin-1
install-CAOS-plugin-1

Type “CAOS” in search and you will find the CAOS plugin

install-CAOS-plugin-2
install-CAOS-plugin-2

Click on “Install“, then click on “Activate

install-CAOS-plugin-3
install-CAOS-plugin-3

Step 2 – Configure CAOS WordPress plugin

If you are using Google Analytics code already then, you might be aware of the Google Analytics tracking ID. It will look something like “GA-*********”. So, we won’t go into finding Google Analytics tracking ID.

To configure the CAOS plugin, follow the steps below

Go to “Settings“, then click on “Optimize Google Analytics

Paste your Google Analytics tracking ID in “Data Stream Measurement ID

Configure-CAOS-plugin-1
Configure-CAOS-plugin-1

Now scroll down to “Tracking Code” and choose as per your requirement

Note* - If you have a blog, then choose "Minimal Analytics 4" as it gives analytics about pageviews and events. But if you have a woocommerce website, then you must choose "Asynchronous (default)" dropdown.

Click “Save Changes & Update

Configure-CAOS-plugin-2
Configure-CAOS-plugin-2

That’s it, you have successfully hosted Google Analytics locally on WordPress.

Share your love by sharing
Sourabh Verma
Sourabh Verma

I.T Engineer by profession, tech lover. Passionate for reading and writing technical stuffs. Loves to share knowledge.

Leave a Reply

Your email address will not be published. Required fields are marked *