📜 ⬆️ ⬇️

Now Google Analytics is Asynchronous.

The new code looks like this:
var _gaq = _gaq || [];
_gaq.push([ '_setAccount' , 'UA-XXXXX-X' ]);
_gaq.push([ '_trackPageview' ]);

( function () {
var ga = document .createElement( 'script' );
ga.src = ( 'https:' == document .location.protocol ? 'https://ssl' :
'http://www' ) + '.google-analytics.com/ga.js' ;
ga.setAttribute( 'async' , 'true' );
document .documentElement.firstChild.appendChild(ga);
})();

This means that Google Analytics will no longer slow down the loading of your site :)
UPD: That is, he downloaded his 24kb ga.js while loading the page, now he can do it after ...
But after the first download, it is usually cached and the same is used on all other sites :)

Materials on the topic:

We take into account the CIS search engines

var _gaq = _gaq || [];
_gaq.push(
[ '_setAccount' , 'UA-XXXXXX-X' ],
[ '_setDomainName' , 'your.domain.name' ],
[ "_addOrganic" , "mail.ru" , "q" ],
[ "_addOrganic" , "rambler.ru" , "words" ],
[ "_addOrganic" , "nigma.ru" , "s" ],
[ "_addOrganic" , "blogs.yandex.ru" , "text" ],
[ "_addOrganic" , "webalta.ru" , "q" ],
[ "_addOrganic" , "aport.ru" , "r" ],
[ "_addOrganic" , "akavita.by" , "z" ],
[ "_addOrganic" , "meta.ua" , "q" ],
[ "_addOrganic" , "bigmir.net" , "q" ],
[ "_addOrganic" , "tut.by" , "query" ],
[ "_addOrganic" , "all.by" , "query" ],
[ "_addOrganic" , "i.ua" , "q" ],
[ "_addOrganic" , "online.ua" , "q" ],
[ "_addOrganic" , "a.ua" , "s" ],
[ "_addOrganic" , "ukr.net" , "search_query" ],
[ "_addOrganic" , "search.com.ua" , "q" ],
[ "_addOrganic" , "search.ua" , "query" ],
[ "_addOrganic" , "poisk.ru" , "text" ],
[ "_addOrganic" , "km.ru" , "sq" ],
[ "_addOrganic" , "liveinternet.ru" , "ask" ],
[ "_addOrganic" , "gogo.ru" , "q" ],
[ "_addOrganic" , "gde.ru" , "keywords" ],
[ "_addOrganic" , "quintura.ru" , "request" ],
[ '_trackPageview' ]
);

( function () {
var ga = document .createElement( 'script' );
ga.src = ( 'https:' == document .location.protocol ? 'https://ssl' : 'http://www' ) + '.google-analytics.com/ga.js' ;
ga.setAttribute( 'async' , 'true' );
document .documentElement.firstChild.appendChild(ga);
})();


* This source code was highlighted with Source Code Highlighter .

')

Source: https://habr.com/ru/post/77123/


All Articles