How To Host Google Analytics Locally In WordPress (2020)| Fix Your Leverage Browser Caching Issue In Gtmetrix

BY:Sandip Maheshwari
Last Updated:Last updated Jul 11, 2020
Category:WP SPEED
how to host google analytics locally in wordpress

In this tutorial, you will learn how you can host your Google Analytics code locally in WordPress & Improve your Gtmetrix, Pingdom, Google page speed score.

 

You might see a leverage browser caching issue on your Gtmetrix report if you are using Google Analytics (Or Google Tag Manager code).

To fix this issue, we can host the Google Analytics tracking code locally. So, in this post, I will show you how to host your Google analytics code locally on your WordPress website.

So, let’s get started.

How To Fix Google Analytics Leverage Browser Caching Warning In WordPress

I have shared 5 plugins that will help you to fix your Google Analytics leverage browser caching warning in WordPress.

 

1. CAOS | Host Google Analytics Locally

 how to speed up woo-commerce website

There are many plugins to host Google analytics code locally. I use CAOS | Host Google Analytics Locally plugin which is a free plugin & has great reviews.

CAOS Plugin Setting:

Basic Settings:

 leverage browser caching google tag manager wordpress

Google Analytics Tracking ID – Enter your tracking id here.

Allow Tracking – Always

Snippet Type – Default

Position of tracking – code: Header

Advanced Settings:

 caos plugin settings

Enable Compatibility Mode: If you are using any other Google Analytics plugin like WooCommerce Google Analytics integration, GADP for WP, GAD for WP, or GADP for WP by monster insights then you can link that plugin with CAOS. Choose NONE if you are not using any other GA plugin.

Which File to Download – Analytics.js 

Save Analytics.js to  – Here you can change the path where the analytics cached inside the WordPress directory. This is up to you, you can change the path or leave it as it is.

Serve From a CDN – If you are using any CDN, then enter your CDN URL here.

Enable Preconnect – Enable. This will speed up the requests to the servers.

Capture Outbound Links – Enable this. Capturing outbound links will help you in retargeting ads.

Cookie Expiry Period (days) –   Here you can set the cookie expiry period. 

Change Enqueue order – Let it be default.

Disable All display features functionality – disable this option 

Anonymize IP – Enable this, as it is required by law in some countries (GDPR Compliance) which will prevent the collection of user’s data.

Track Logged In Administrators –  Disable this option.

Remove Setting at Uninstall –  Enable this option.

 

2. Swift Performance Lite

 google analytics local file 

Swift performance lite is a free cache plugin (also has a pro version) & has an option to host Google Analytics locally. All you have to do is go to the tools > swift performance lite setting > General > Google Analytics.

 google analytics localhost

 

Bypass Google Analytics – On.

Tracking ID – Here you have to paste your Google Analytics tracking UA ID.

Anonymize IP – On.

 

3. WP Rocket

 how to optimize your wordpress site speed with Wp fastest cache

WP Rocket is a premium plugin for WordPress speed optimization. You don’t have to install 6 extra plugins as this plugin covers minification, database cleaning, hosting google fonts, image optimization, etc. So, If you are using WP Rocket then you can host analytics locally. All you have to do is to go to the Add-ons tab and Turn ON Google analytics.

 google analytics slow page load

 

 

4. Perfmatters

 host google tag manager locally

Perfmatters is a premium plugin by Kinsta which also helps in improving the WordPress website by disabling plugins & unnecessary WordPress features. This plugin also has a feature to host your Google Analytics code locally.

Install and activate this plugin. Then go to the settings > Perfmatters > Google Analytics

 fix leverage browser caching issue

 

Enable Local Analytics – On.

Tracking ID – Enter your tracking id here.

Tracking Code Position – Choose Header.

Disable Display Features – OFF.

Anonymize IP – On.

Tracking Logged In Admins – OFF.

Use Monsterinsights – If you are using Monsterinsights plugin then turn this ON, otherwise turn this OFF.  

 

5. Flying Analytics

 host google analytics locally wordpress

Flying Analytics is another lightweight plugin that also helps you to host your analytics code locally.

Install and activate this plugin.

Next, Go to the settings > flying analytics

 google analytics locally in WordPressgoogle analytics locally in WordPress

 

Google Analytics Tracking ID – Enter your Tracking id here.

Javascript method – This plugin offers 4 types of js methods to choose from.

 fix leverage browser caching wordpress google analytics

Disable for logged in Admins – Check this box.

 

Conclusion:

You can choose any plugin mentioned above to host the Google Analytics code locally in WordPress. It is a great way to improve your GTmetrix, Page Speed Score, and Pindom score and fix your leverage browser caching warning.

Also, check out my blog on how to improve your WordPress website speed with 100% Score.

If you have any queries on WordPress, then feel free to comment below.

Sandip Maheshwari
Written By Sandip Maheshwari

A guy blogging for the last 3 years, I am a guy who loves to write about SEO, social media and affiliate marketing. An avid cricket fan, die-hard fan of Silicon valley the series. I love to blog in my free time to share my knowledge with people around the world.

Summary
How To Host Google Analytics Locally In Wordpress
Article Name
How To Host Google Analytics Locally In Wordpress
Description
You can host Google Analytics code locally in Wordpress by using plugin. I have shared 5 plugins to host your analytics code locally. I use CAOS plugin. 1.CAOS Host Google Analytics Locally 2.Swift Performance Lite 3.WP Rocket 4.Perfmatters 5.Flying Analytics
Author
Publisher Name
Digirockstar
Publisher Logo
SITEGROUND HOSTING
Malcare PLugin

Malware Scanner & Security for WordPress

Read Our Malcare plugin Review
Greengeeks HOSTING

$2.95/pm

60% Discount

Read Our Greengeeks Review

0 Comments

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.