Web analytics: Improve Web page performance with locally managed ga.js files

Source: Internet
Author: User

Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall

Google Anlytics Analysis Code is asynchronous loading, generally does not affect the performance of the Web page, but the Technical department's web page performance report always mentions the state of Ga.js as aborted, that GA is asynchronous tracking, but in some cases, the performance of the Web page and load time does have an impact. Does Google Analytics code affect Web page performance? is local hosting ga.js feasible? This article provides the basic idea and implementation method of local server hosting ga.js.

Google Anlytics Analysis Code is asynchronous loading, generally does not affect the performance of the Web page, but the Technical department's web page performance report always mentions the state of Ga.js as aborted. The request aborted state, meaning that the request was terminated, because we are in a certain area of the network environment (you know). How to solve the non-GA code request ga.js loading speed? There are no more than three solutions on the web, but basically they are modifying the tracking code, such as deleting http: and https: judgment, ignoring cookie incomplete checks, and so on. But Seo Xiangzi thinks: the thorough way to improve ga.js availability is "local hosting ga.js, porting ga.js to local server". This article after testing, and webmaster/seo friends to share the implementation process.

  

Localized ga.js: Locally hosted ga.js files, Web page performance/load time God's horses are clouds.

Will Google Analytics code affect Web page performance?

Communicating with some webmasters, or Web site data analysts, found that most people's view is "because GA tracking is an asynchronous trace mode, it does not affect page performance." At this point, Seo Cheung has his own reservations: Yes, at the end of 2009, Google Analytics launched the GA Asynchronous tracking code, performance compared to the previous synchronization tracking code in the performance of the Web page has a leap-forward upgrade. However, Xiangzi based on many years to do the station and SEO experience, GA is not the asynchronous tracking is foolproof!

1. First, we have to base on a premise, GA uses asynchronous statistical mode, greatly improve the performance of the Web page. But we can't ignore that: the client browser still downloads about 35.9KB of ga.js files, which are downloaded from a Google server in the state of California.

2. Our network environment is not very ideal, although the possibility of Google Server is very high, but for Chinese users, the successful connection rate has a significant impact. I have consulted the relevant data, the Chinese users open www.google.com availability rate of 92% or so, www.google-analytics.com/ga.js is a high probability, but that is 99.2% up and down. This is 2011 data, into the 2012, the situation is worse, Google analytics site more difficult to open.

3. The Ga.js browser cache cycle is 12 hours, and users access different Web sites that use GA analysis to load the same ga.js file. means that users are not required to reload files when they visit different Web sites. This is a good news. However, given the connectivity of Google users in mainland China, there are not too many sites using GA analytics, and the Ga.js 12-hour cache cycle, which will reload the file if the user visited the GA site 12 hours ago; There are also parts of users who have never loaded ga.js without a browser, not to mention that Web page performance is certainly affected. To sum up, GA code, although the probability of impact on Web page performance is very small, but for some users still have the risk of loading Ga.js file failure.

is local managed ga.js feasible?

So will ga.js localization be able to track access effectively? Ga.js are you allowed to localize?

Check out Google Analytics Help Center "local hosting Ga.js file", Google is allowed Ga.js local hosting, but it does not seem to encourage this.

The following is Google's description of ga.js localization:

(http://support.google.com/analytics/bin/answer.py?hl=zh-Hans&cbrank=3&cbid=-1wzhmp8d849hu&answer= 1032389)

Google Help Center: Local managed ga.js files

Although you can download files for inspection, we recommend that users do not host ga.js. Most people want to host ga.js locally in order to avoid site visitors downloading the file from Google every time they request a page. However, regardless of where Ga.js is hosted, it is only downloaded once and then cached (saved) in the visitor's browser for subsequent web browsing. Therefore, it is most advantageous for you and your visitors to refer to ga.js files from Google's servers. This ensures that you are using the latest version: As long as there are new features and other improvements, it will be available to you immediately. This will help us to ensure the accuracy of your reports as much as possible.

Basic ideas for local server hosting Ga.js:

The idea of hosting Ga.js to a local server is simple:

1. Download Ga.js to local server with program;

2. Check the ga.js files regularly, keep the local server as the latest version of the file;

3. Modify and embed the tracking code into the Web page;

4. Successfully sent the analysis data, the GA account receives the report.

Download ga.js files from Google server to local server, update cycle-per day:

How to download Www.google-analytics.com/ga.js file with code, SEO Xiangzi in "ASP Source code: Get Web page code, generate file Http://www.giigift.com/blog/post/294.html" has been explained, this article will no longer boil down, the text to share the source code for ASP (sad reminders, I am a only understand ASP SEO), other languages please google similar method.

It is worth mentioning that the Ga.js file will update the content, if the use of the old version of GA files, may cause trace problems, so you need to keep the local server ga.js as the latest version, I would like to update once a day, should be no problem.

Embed GA code in Web pages

The local server already has the latest version of the Ga.js file, just modify the page tracking code can be modified, the main content is to GA.SRC modified. If your site does not use https://, then you can simplify the code, delete the page is http: or https: the judge can. The following is the test of Xiangzi:

< script type= "Text/javascript" >

var _gaq = _gaq | | [];

_gaq.push ([' _setaccount ', ' ua-232915-7 ']);

_gaq.push ([' _trackpageview ']);

(function () {

var ga = document.createelement (' script '); Ga.type = ' Text/javascript '; Ga.async = true;

GA.SRC = ' http://www.giigift.com/local server directory/ga.js ';

Because you do not need to determine whether the page is https:

Can ga.src = (' https: ' = = Document.location.protocol? ' Https://ssl ': ' http://www ') + '. Google-analytics.com/ga.js ';

Instead: GA.SRC = ' Your local ga.js address ';

var s = document.getelementsbytagname (' script ') [0]; S.parentnode.insertbefore (GA, s);

})();

</script >

This article author Seo xiangzi on December 14, 2012 to carry out the above step, to the dispatch of December 26 8:40,ga received data normal.

This article from Gillie Network Marketing Blog, reproduced and please specify the source: http://www.giigift.com/blog/post/295.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.