Google's tracking code dynamically loads js Code Method Applications

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var _ gaq = _ gaq | []; // If the Variable _ gaq exists, it is equal to itself; otherwise, it is an empty array.
_ Gaq. push (['_ setaccount', 'ua-24479793-2']); // It is a two-dimensional array _ gaq [0] = array (0 => '_ setaccount ', 1 => 'ua-24479793-2 '); (set the Google account corresponding to this tracking code) _ gaq. push (['_ trackPageview']); // It is a 2-dimensional array _ gaq [1] = array (0 => '_ trackPageview'); (defines tracking by page) (function (){
Var ga = document. createElement ('script'); // create a <script> tag
Ga. type = 'text/javascript '; // <script type = "text/javascript">
Ga. async = true; // This attribute does not seem to exist in async asynchronous scripts.
Ga. src = ('https: '= document. location. protocol? 'Https: // ssl ': 'http: // www') + '.google-analytics.com/ga.js'; // If https:, assign src to the https://ssl.google-analytics.com/ga.js or http://www.google-analytics.com/ga.js var s = document. getElementsByTagName ('script') [0]; // locate the first <script> tag on the current page.
S. parentNode. insertBefore (ga, s); // Add the <script> created by dom to the back of the first <script> tag on the page.
})();
/**
Dynamically load js Code to asynchronously download js Code. Reduces blocking during js file download. Google tracking code **/</script>

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.