To speed-up Google Analytics

>> Thursday, June 14, 2012

To speed-up Google Analytics
hello friends,

I have downloaded Google Anaytics few days back. Whenever I start GA, it takes lots of time to start and process. Googla Analytics is so popular, then why is this happening.....
Can anyone help me with how can I speed up Google Analytics ?

#2
02-04-2009

Techguru01
Member

Join Date: Oct 2005
Posts: 2,116
Re: To speed-up Google Analytics
Since Google Anaytics is very much popular amongst website developers and
website monitors, so when google-analytics.com/urchin.js is requested by billions of web users all over the world at one time, it can cause your sites pages to load at a snails pace. Especially if you are using WordPress or a similar CMS.

#3
02-04-2009

Techno01
Member

Join Date: Apr 2008
Posts: 2,268
Re: To speed-up Google Analytics
Use the following script -

Code:


Shell Script to Update ga.js
Here is an updated shell script that fetches the latest ga.js file from google and places it in the folder of your site.

Code:
#!/bin/sh

# TMP DIRECTORY
MYTMP=/tmp/

# SAVE ga.js HERE
INSTALL_IN=/home/user/askapache.com/z/j/

# RESOURCE URLS
GOOGLE_GA_URL=http://www.google-analytics.com/ga.js

# USER-AGENT
UA="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"

# CD TO TMP DIRECTORY
cd $MYTMP

# DOWNLOAD THE FILE
curl --header "Pragma:" -f -s -A "${UA}" -m 1800 --retry 15 --retry-delay 15 --max-redirs 8 -O $GOOGLE_GA_URL

# GIVE FILE CORRECT PERMISSIONS
chmod 644 $MYTMP/ga.js

# COPY FILE TO SITE DIRECTORY
cp -r $MYTMP/ga.js $INSTALL_IN

# RETURN TO OLDPWD
cd $OLDPWD

exit 0;
Code:
Updating ga.js with Crontab
Just add this to your crontab by typing crontab -e where google-analytics-update.sh is the location of your shell script.
@daily /home/user/scripts/google-analytics-update.sh >/dev/null 2>&1

#4
02-04-2009

Techguru01
Member

Join Date: Oct 2005
Posts: 2,116
Re: To speed-up Google Analytics
The method already mentioned above(by Techno01) uses crontab to execute a shell script that downloads an updated urchin.js file every 24 hours and saves it into your local sites directory.
Thats it!

There are 2 major things that you accomplish by hosting urchin.js locally:
You Enable persistant connections
You ensure that the correct 304 Not Modified header is sent back to your site visitors instead of reserving the entire file.

Note -
One problem with remote hosted urchin.js is the server that the urchin.js file is served from does not allow persistant connections.

Another big reason is that even though Cache-Control headers are correctly set by google-analytics when serving urchin.js, instead of responding to an If-Modified-Since header correctly with a 304 Not Modified header, indicating the file has not been modified, google-analytics instead returns the entire urchin.js file again, thus rendering the cache-control void.

#5
02-04-2009

Jackson2
Member

Join Date: Apr 2008
Posts: 2,265
Re: To speed-up Google Analytics
To truly speed up your site,
You will want to implement a server-side caching technique.
Or
You can read more about caching and web cache.

Apache Caching Guide
This document supplements the mod_cache, mod_disk_cache, mod_mem_cache, mod_file_cache and htcacheclean reference documentation.

It describes how to use Apache’s caching features to accelerate web and proxy serving, while avoiding common problems and misconfigurations.

0 comments:

Post a Comment

Read - Share - Comment

About This Blog

Share and Save

About Author