Results 1 to 5 of 5

Thread: To speed-up Google Analytics

  1. #1
    Join Date
    Feb 2009
    Posts
    34

    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. #2
    Join Date
    Oct 2005
    Posts
    2,358

    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. #3
    Join Date
    Apr 2008
    Posts
    2,276

    Re: To speed-up Google Analytics

    Use the following script -

    Code:
    <script src="/j/ga-151.js" type="text/javascript"></script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-732153-7");
    pageTracker._initData();pageTracker._trackPageview();
    </script>
    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. #4
    Join Date
    Oct 2005
    Posts
    2,358

    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:
    1. You Enable persistant connections
    2. 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. #5
    Join Date
    Apr 2008
    Posts
    2,277

    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.

Similar Threads

  1. What is Google Analytics ?
    By Demetrius in forum Technology & Internet
    Replies: 7
    Last Post: 02-11-2011, 11:47 PM
  2. I am new to Google Analytics
    By Haviva in forum Technology & Internet
    Replies: 5
    Last Post: 31-01-2011, 11:37 PM
  3. Google Analytics: Bad Reporting
    By Elizabeth%allen in forum Technology & Internet
    Replies: 4
    Last Post: 28-01-2011, 07:33 PM
  4. Google Analytics Tutorial
    By $Jaganmohini$ in forum Technology & Internet
    Replies: 3
    Last Post: 25-01-2011, 06:27 PM
  5. How To Get Rid Of Google Analytics
    By Bao in forum Technology & Internet
    Replies: 4
    Last Post: 19-07-2010, 02:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,701,433,996.69346 seconds with 17 queries