Analytics.js Introduction

Source: Internet
Author: User

Analytics.js JavaScript code Snippets are a new way to measure how users interact with your site. It is similar to the previous tracking code ga.js, but provides greater flexibility for developers to customize the implementation.

The Analytics.js code snippet is part of the Universal Analytics ( currently in Beta) phase. New users should use Analytics.js. Existing Ga.js users should create new network media resources for Analytics.js and make two code implementations in their sites. Adding Ga.js and Analytics.js code snippets on the same page does not have any security issues.

Quick start of tracking code

To start using the Analytics.js tracking site, paste the following JavaScript snippet in front of the end tag in the site template page . The UA-XXXX-Y parameter must be replaced with the network Media Resource ID of the Google Network media resource that you want to track.

<!--Google Analytics--><script> (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 ', '// ', ' ga '); GA (' Create ', ' ua-xxxx-y ', ' Auto '), GA (' send ', ' PageView ');</script><!--End Google Analytics--

The code runs asynchronously loads the Google Analytics tracking code onto the page and then UA-XXXX-Y creates a tracker object for the network media resource that you specify in the parameters. Finally, it records web browsing in Google Analytics for pages that run scripts.

Reference point

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: 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.