Google Anlytics Analysis Code is asynchronous loading, generally does not affect the performance of the Web page, but the technical department of the Web performance report is always mentioned ga.js status of aborted, stating that although GA is asynchronous tracking, but in some cases, the performance of the Web page and load time does have an impact
Will Google Analytics code affect Web performance? Is it possible to host ga.js locally? This article provides the basic idea and implementation method of local server hosting ga.js.
Google Anlytics Analysis Code is loaded asynchronously, generally does not affect the performance of the Web page, but the technical department's Web performance report always mentions that ga.js status is aborted. The request aborted state, meaning that the request was terminated, is simple because we are in a particular area of the network environment (you know). So how to solve the non-GA code request ga.js loading speed? There are no more than three programs found on the Internet, but basically it is to modify the tracking code, such as the removal of http: with https: the judgment, ignoring the cookie incomplete check. However, the author believes that the complete solution to improve the usability of Ga.js is "locally hosted ga.js, porting ga.js to the local server". This article after the measurement, with the webmaster/seo friends to share the implementation process.
Localization ga.js: Local hosted Ga.js file, Web performance/load time the gods and horses are clouds.
Will Google Analytics code affect Web performance?
When communicating with some webmasters or web-site data analysts, the majority view is that "because GA tracking is an asynchronous tracking pattern, it does not affect page performance". At this point, SEO Xiangzi has its 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. However, Xiangzi based on years of doing the station and SEO experience, GA is not an asynchronous tracking is foolproof!
1. First, we want to base on a premise, GA uses the asynchronous statistic pattern, greatly improves the webpage performance. But we can't ignore it: The client browser still downloads approximately 35.9KB of the Ga.js file, which is downloaded from a Google server in California, USA.
2. Our network environment is not very ideal, although the likelihood of Google server is very high, but for Chinese users, the success of the connection rate has a significant impact. I have consulted the relevant information, Chinese users open www.google.com availability rate is about 92%, www.google-analytics.com/ga.js the likelihood rate is much higher, but that is 99.2% up and down. This is 2011 data, in 2012, the situation is even worse, Google analytics site more difficult to open.
3. Ga.js Browser Cache cycle is 12 hours, and users access different sites using GA analysis, loading the same ga.js file. means that users do not need to load files repeatedly when they visit different websites. That's a good news. However, given Google's connectivity to users in mainland China, there are currently not too many sites using the GA analysis system, which is affected by the Ga.js 12-hour cache cycle, and the file will be reloaded if the user visited a website using GA 12 hours ago There are also parts of users without browsers that have never been loaded ga.js, not to mention the Web performance is definitely affected.
In summary, although the GA code on the Web page performance impact is very small, but for some users still have the risk of loading Ga.js file failure.
Is it possible to host ga.js locally?
So, can ga.js localization effectively track access? Does ga.js allow localization?
Google Analytics Help Center "locally hosted Ga.js file" is available for ga.js local hosting, but it does not seem to encourage this.
Here's a description of Google's localization for ga.js:
(http://support.google.com/analytics/bin/answer.py?hl=zh-Hans&cbrank=3&cbid=-1wzhmp8d849hu&answer= 1032389)
Google Help Center: locally hosted Ga.js files
Although you can download files for inspection, we recommend that users do not host ga.js themselves.
Most people want to host ga.js locally to prevent site visitors from downloading the file from Google every time they request a webpage. However, regardless of where Ga.js is hosted, it is downloaded only 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 soon as there are new features and other improvements, it will be available to you immediately. This will help us to ensure that you report the accuracy as much as possible.
The basic idea of local server hosting Ga.js:
The idea of hosting Ga.js to a local server is simple:
1. Download Ga.js to the local server using the program;
2. Check the Ga.js file 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 make analysis data, GA account receives report.
Download ga.js files from Google server to local server, update cycle-every day.
It is worth mentioning that the Ga.js file will be updated irregularly, if you use the old version of the GA file, may cause trace problems, so need to keep the local server ga.js to the latest version, I would like to update one day, should be no problem.
Embed GA code in Web pages
The local server has the latest version of the Ga.js file, just modify the page tracking code, the main content of the modification is to change the ga.src. If your site does not use https://, then you can simplify the code, delete the page is http: or https: the judgment can be. The following is the test code, validated, GA receives normal data.
Copy CodeThe code is as follows:
<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 put 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> Transferred from: http://www.jb51.net/yunying/70962.html
Improve Google Anlytics performance by loading ga.js files locally