Use of Google-analytics: parse page introduction code

Source: Internet
Author: User
Code sorting and comments
// Create the GA () method and load analytics. JS file // A and m are used as parameters to ensure that the following execution does not modify external variables with the same name (function (Win, Doc, O, G, Ga, a, m) {win ['googleanalyticsobject '] = Ga; // exposes the GA object externally. // make sure that only one analytics is executed. JS insert win [Ga] = Win [Ga] | function () {(WIN [Ga]. Q = Win [Ga]. q | []). push (arguments)}, win [Ga]. L = 1 * new date (); // converts the time format to a numeric type // dynamically loads analytics. js a = Doc. createelement (O), M = Doc. getelementsbytagname (o) [0]; // script. async = 1;. src = g; M. parentnode. insertbefore (a, m);}) (window, document, 'script', '// www.google-analytics.com/analytics.js', 'ga ');

A short piece of code is quite informative.

Compressed code
(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),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‘);

Reference: https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced? Hl = ZH-TW

Use of Google-analytics: parse page introduction code

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.