How To Host Google Analytics Locally In WordPress: This Fixes The “Leverage Browser Caching” Issue In GTmetrix For Google Analytics

If you’re using Google Analytics on your WordPress site, you might see a leverage browser caching issue in your GTmetrix report.

Hosting your Google Analytics tracking code locally should fix this. There are many plugins to host analytics locally, which is as easy as copying and pasting your UA number into the plugin.

You have a few plugin choices: I recommend WP Rocket’s Google Tracking add-on if you’re already use it as your cache plugin. Otherwise, CAOS | Host Google Analytics Locally works.

Leverage Brower Caching Google Analytics

Backup Your Google Analytics Data: it’s a good idea to backup your Google Analytics data before hosting your tracking code locally. To do this, login to your Google Analytics account, navigate to a report, click Export (top right), then click the file type you want it exported to.

How To Host Google Analytics Locally

  1. CAOS
  2. WP Rocket
  3. Perfmatters
  4. Swift Performance
  5. Clearfy

 

1. CAOS | Host Google Analytics Locally

CAOS has great reviews and it’s sole purpose is to host Google Analytics locally.

CAOS-Analytics

In the CAOS settings, copy/paste your Google Analytics Tracking ID into the plugin. Next, choose to always allow tracking or when cookies are set, not set, or when they have a value.

CAOS Analytics Settings

In the advanced settings, the main things you want to look at are:

CAOS Analytics Settings

 

2. WP Rocket

To host analytics locally in WP Rocket, go to the Add-ons tab and enable Google Tracking.

WP Rocket Local Analytics

 

3. Perfmatters

Perfmatters is a premium plugin by Kinsta and basically takes care of the last 10% of WordPress speed optimization. It has options to host Google Analytics locally, selectively disable plugins (similar to Asset CleanUp), and disable unnecessary WordPress features.

To host fonts locally using Perfmatters, enter your Tracking ID and configure the settings:

Local Analytics Perfmatters

 

4. Swift Performance

Swift Performance is a cache plugin that has gotten a lot of praise in the WordPress Speed Up Facebook Group and also has an option to bypass Google Analytics. Enter your Tracking ID and configure the settings, which are pretty much the same as the other local analytics plugins.

Swift Performance Bypass Google Analytics

 

5. Clearfy

Clearfy has great reviews and helps with speed, security, and SEO. It’s a multipurpose plugin that not only hosts analytics locally, but has other miscellaneous features that are also useful.

Clearfy Google Analytics Cache

 

What’s Next?

Glad you asked.

I have some awesome tutorials on how to fix a slow WordPress site.

Whether you need to configure the WP Rocket settings, reduce server response time, or optimize external scripts, I have tutorials for it all which you can find in the navigation menu and sidebar. Leave a comment if you have any questions and I’ll be glad to help you out.

Cheers,
Tom

Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments