So the big hurdle with speeding up a WordPress site that users run into almost all the time is speeding up scripts that run on other sites.   In the process of WordPress Speed Optimization it is very routine to speed up the scripts that reside on the actual server the site is running on but you can not do that on those scripts that need to be called on to load from other sites.  Believe us we know the frustration of this fact all too well.

A script that you will find on the majority of WordPress sites is Google Analytics.  This is used often because it is an amazing tracking tool to study and research your site traffic.  Now in general the script itself is pretty fast and stable.  But we do see that from time to time the loading of this script will spike and cause the entire load time of any page on your site to slow down.

We we have a solution that will allow you to bring this script into your world so you can load it faster.  We have used this technique on hundreds of sites and have seen amazing consistent increases in speed.  Take a look below at the before and after speed test results.

WordPress Support

WordPress Support

So now let us get into the actual process of making this happen so you can gain some more speed!

Make The Google Analytics Script Local

First thing you need to do is to take the actual script file needed to run Google Analytics and put it on your server. We have created this file for you which you can download at the link below. This is a file has been zipped up so make certain you unzip it before using it.

After you do unzip it, place it in a location on your hosting account. A very common place for this is inside of your child theme somewhere but it does not really matter where you place this file as long as you know the full path to it. An example path would be

Load the Local Google Analytics Script

So now you are going to adjust the code below replacing where it says FULL_PATH_TO_FILE with the path to where you placed the gas.js file. You will also need to replace the area in the code that says GA_TRACKING_ID with your unique ID. Then this code will be placed in your website before the closing tag. Be sure to remove the code you used prior to run Google Analytics.

var _gaq = [['_setAccount', 'UA-GA_TRACKING_ID'], ['_trackPageview']];
 setTimeout(function() {
 var g = document.createElement('script'),
 s = document.scripts[0];
 g.src = 'FULL_PATH_TO_FILE';
 s.parentNode.insertBefore(g, s);
 }, 0);

Doing this simple process will surely Speed Up Google Analytics and make sure it loads fast consistently. SPEED BABY!!!!

Here is a Plugin that will do all this for you

WordPress Support
A cool plugin created by Daan van den Bergh that enables you to complete optimize the usage of Google Analytics on your WordPress Website. Host your Google Analytics javascript-file (analytics.js) locally and keep it updated using wp_cron(). Easily Anonymize the IP-address of your visitors. Set an Adjusted Bounce Rate. Decide whether to load the Analytics Tracking-code in the header or footer. And more! CHECK IT OUT AT