MediaWiki:Common.js/ga.js — различия между версиями
Материал Psylab.info - энциклопедии психодиагностики
м |
м |
||
| Строка 1: | Строка 1: | ||
| − | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | + | /** |
| − | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | + | * Creates a temporary global ga object and loads analy tics.js. |
| − | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | + | * Paramenters o, a, and m are all used internally. They could have been declared using 'var', |
| − | })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | + | * instead they are declared as parameters to save 4 bytes ('var '). |
| − | ga('create', 'UA-26921269-3', 'psylab.info'); | + | * |
| − | ga('require', 'displayfeatures'); | + | * @param {Window} i The global context object. |
| − | ga('send', 'pageview'); | + | * @param {Document} s The DOM document object. |
| + | * @param {string} o Must be 'script'. | ||
| + | * @param {string} g URL of the analytics.js script. Inherits protocol from page. | ||
| + | * @param {string} r Global name of analytics object. Defaults to 'ga'. | ||
| + | * @param {DOMElement?} a Async script tag. | ||
| + | * @param {DOMElement?} m First script tag in document. | ||
| + | */ | ||
| + | (function(i, s, o, g, r, a, m){ | ||
| + | i['GoogleAnalyticsObject'] = r; // Acts as a pointer to support renaming. | ||
| + | |||
| + | // Creates an initial ga() function. The queued commands will be executed once analytics.js loads. | ||
| + | i[r] = i[r] || function() { | ||
| + | (i[r].q = i[r].q || []).push(arguments) | ||
| + | }, | ||
| + | |||
| + | // Sets the time (as an integer) this tag was executed. Used for timing hits. | ||
| + | i[r].l = 1 * new Date(); | ||
| + | |||
| + | // Insert the script tag asynchronously. Inserts above current tag to prevent blocking in | ||
| + | // addition to using the async attribute. | ||
| + | a = s.createElement(o), | ||
| + | m = s.getElementsByTagName(o)[0]; | ||
| + | a.async = 1; | ||
| + | a.src = g; | ||
| + | m.parentNode.insertBefore(a, m) | ||
| + | })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); | ||
| + | |||
| + | ga('create', 'UA-26921269-3', 'psylab.info'); // Creates the tracker with default parameters. | ||
| + | ga('require', 'displayfeatures'); // Display Advertising Features in Google Analytics. | ||
| + | ga('require', 'linkid', 'linkid.js'}; // Load the plug-in. Note: this call will block until the plug-in is loaded. | ||
| + | ga('set', '&uid', {{ USER_ID }}); // Adds User-ID feature. | ||
| + | ga('send', 'pageview'); // Sends a pageview hit. | ||
Версия 06:26, 25 апреля 2014
/**
* Creates a temporary global ga object and loads analy tics.js.
* Paramenters o, a, and m are all used internally. They could have been declared using 'var',
* instead they are declared as parameters to save 4 bytes ('var ').
*
* @param {Window} i The global context object.
* @param {Document} s The DOM document object.
* @param {string} o Must be 'script'.
* @param {string} g URL of the analytics.js script. Inherits protocol from page.
* @param {string} r Global name of analytics object. Defaults to 'ga'.
* @param {DOMElement?} a Async script tag.
* @param {DOMElement?} m First script tag in document.
*/
(function(i, s, o, g, r, a, m){
i['GoogleAnalyticsObject'] = r; // Acts as a pointer to support renaming.
// Creates an initial ga() function. The queued commands will be executed once analytics.js loads.
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
},
// Sets the time (as an integer) this tag was executed. Used for timing hits.
i[r].l = 1 * new Date();
// Insert the script tag asynchronously. Inserts above current tag to prevent blocking in
// addition to using the async attribute.
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-26921269-3', 'psylab.info'); // Creates the tracker with default parameters.
ga('require', 'displayfeatures'); // Display Advertising Features in Google Analytics.
ga('require', 'linkid', 'linkid.js'}; // Load the plug-in. Note: this call will block until the plug-in is loaded.
ga('set', '&uid', {{ USER_ID }}); // Adds User-ID feature.
ga('send', 'pageview'); // Sends a pageview hit.