Get started with Google Analytics
What is Google Analytics
Google Analytics is a Google official analytics tool that is primarily used to help webmasters understand the data on the site and improve the quality of the site.
The Google Analytics Admin action page, as follows:

From the above figure we can see that the page is divided into three parts:
- Header:
Showing all sites monitored, you can choose one of them to view statistics, such as the above dorie site; - Menu Bar:
menu bar, assuming you listen to the dorie site, you can click Home to view the statistics; - Content area:
When you click the one of 'Menu Bar', this area to display the related content.
How to simply use Google Analytics to monitor a given site
- First of all, you have to have a Google Analytics account and sign in, if you do not have to click here to register.
- And then, please prepare a site you need to monitor, such as my test site(www.dorie.top).
- Next Step:
Suppose you are a new user, you follow it suggested that the first need to monitor the site to join into it, like as:
If you are not a new user, click ADMIN-> PROPERTY-> Create new property in the 'Menu Bar', like as:
- Copy and paste this code into every webpage you want to track.
note: every property you created has a different 'Tracking ID', don't rewrite it.
For example, I would add the tracking code I created above to the main page of the dorie.top website:
- Visit the website you want track.
For example, I visited the dorie.top website and return to HOME of 'Menu Bar' in Google Analytics, we can see this:
How amazing it is!
But, how does it do it? Go check the next chapter.
Google Analytics implementation principles
Just now we copy the tracking code to restore, get the next:

If you are a front-end developer, the above code is so easy to read.
The above code has done the following four operations:
- Created a <script> element and started downloading the analytics.js JavaScript library asynchronously from https://www.google-analytics.com/analytics.js.
- Initializes a global function, ga (also known as the ga () command queue), which allows you to schedule commands to be executed when the analytics.js library is loaded.
- Add a command in the ga () command queue to create a new tracker object for the properties specified by the 'UA-104903648-1'.
- Add another command in the ga () command queue to send web browsing data to the current page for Google Analytics.
Read the above steps, I do not know if there is any doubt:
- since the reference to analytics.js is asynchronous, then ga is how to do in the implementation of analytics.js completed after the implementation of it?
- ga ('send', 'pageview') specific meaning?
|
Question
|
Explanation
|
|---|---|
| 1 | In JavaScript, the function is also an object, which means that the function can also contain attributes. The trace code segment defines a q attribute with a null value on the ga function object. Calling the ga () function will attach a list of arguments passed to the ga () function to the end of the q array before the analytics.js library has not yet loaded. When analytics.js is loaded, it will immediately view the contents of the ga.q array and execute each command in turn. Then, the ga () function will be redefined to immediately execute the subsequent call. So, when using the ga () command queue, you do not have to worry about whether the analytics.js library has finished loading. |
| 2 |
Send is a built-in command, the function is to Google Analytics to send the corresponding matching information, such as the built-in method pageview here, we use pageview to measure the number of visits to specific pages on the site, so that is why Google Analytics will show the current user. For example, I set page field in original code in dorie.top website to tell Google Analytics which page the pageview message from. Tip: Google Analytics contains these build-in method you can use: |
When we read the explanation of the Question2, we may have some question, although Google Analytics has some built-in methods and fields, such as pageview and pageview's title, page, etc., but in actual needs, we may need more data, then how to do?
Go check the next chapter.
How to customize dimensions and metrics
When we need to add some additional fields, we can configure the required fields in Google Analytics by 'ADMIN → PROPERTY → Custom Definitions' path.
Note: Each of the different custom dimensions and custom metrics in each property can use 20 exponents. Both the custom and custom metrics for the Premier account can use 200 exponents.
For example, we customized 'name' dimensions and 'age' metrics in the correct path.


And we copy them to the index.html of dorie.top, then we visited the www.dorie.top by change the value of 'name' dimensions and 'age' metrics for simulating the real scene.
like as:

Then, we can get some real data from Google Analytics for 24 hours later.
like as:


It is easy to customize dimensions and metrics, but we need to pay attention to two places:
- dimensions scope:
The range determines which matches will be associated with a custom dimension value. The range is divided into four levels: product , match , session and user :
- Hit -value will be applied to setting a single match for this value.
- Session -value will apply to all matches in a single session.
- User -value will be applied to all matches in the current and future sessions until the value changes or the custom dimension is set to invalid.
- Product -value will be applied to products that set this value (enhanced e-commerce only).
- metrics scope:

Similar to custom dimensions, custom metrics are also divided into different ranges. Hit scope are associated with all match-level dimensions that are sent to the system.
Likewise, product scope metrics are associated only with the product that is sent to the system.
References
2. Google Analytics Developers
3. GA(Chinese)
Get started with Google Analytics的更多相关文章
- 使用 Google Analytics 跟踪 JavaScript 错误
Google Analytics(谷歌分析)不仅仅是一个流量统计工具,你还可以用它来测量广告活动的有效性,跟踪用户多远到所需的页面流(从点击广告到购物车到结账页面)获取,并基于用户的信息设置浏览器和语 ...
- Google Analytics统计代码GA.JS中文教程
2010-12-06 11:07:08| 分类: java编程 | 标签:google analytics ga js 代码 |举报|字号 订阅 Google Analytics ...
- Google Analytics与百度统计原理
Google Analytics与百度统计的统计数据都是有差异的,而且差异非常大,其根本原因在于数据统计的原理和机制是不同的.下面分享一下两位博友李鑫和赵高欣对Google Analytics与百度统 ...
- Google Analytics Premium VS Adobe Analytics
在很久以前的互联网年代,Google收购了一家名为Urchin的公司,进而演化诞生了Google Analytics.当Goochin(Google / Urchin)首次亮相时,它被所有人称为“新的 ...
- 用Google Analytics跟踪JavaScript Errors (译)
通过custom events来实施 // Track basic JavaScript errors window.addEventListener('error', function(e) { _ ...
- Google Analytics SEO 实时 网站 访问量 统计
/*************************************************************************** * Google Analytics SEO ...
- Google Analytics:为链接点击设定事件追踪的方法
在 Google Analytics 中,可以使用 Event Tracking 功能跟踪自定义的事件.但是,如果你要跟踪的是一个链接点击,那么单纯这样写则很有可能导致漏掉许多事件: <a hr ...
- 【转载】国内网站博客数据统计选免费Google Analytics还是百度统计
[转载]国内网站博客数据统计选免费Google Analytics还是百度统计 Google Analytics谷歌统计是我用的第一个网站统计工具,当然现在也一直在用.Google Analytics ...
- 【转载】Google Analytics 使用图文全攻略
转载自:Google Analytics 使用图文全攻略 最近一段时间,因为工作的需要,小励使用GA(GA是Google Analytics的简称)比较频繁,所以花时间研究了一下,从不太了解到会使用( ...
- [翻译]在Django项目中添加谷歌统计(Google Analytics)
原文:<Google Analytics tracking code into Django projects, the easy way> 对我来说,制作一个可扩展的Django应用随时 ...
随机推荐
- php用PHPWord库生成word文档的例子
<?php require_once '../libs/PHPWord/PHPWord/IOFactory.php'; require_once '../../config.php'; $PHP ...
- Python自学笔记-生成器(来自廖雪峰的官网Python3)
感觉廖雪峰的官网http://www.liaoxuefeng.com/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. 生成器 通过列 ...
- 执行manage.py syncdb提示Unknown command: 'syncdb'
1. 实验环境 ubuntu14.4 + django1.9.7 2. 问题描述 在配置完数据库mysite/settings.py后,通常需要运行 python manage.py syncdb 为 ...
- Java面向对象 正则表达式
Java面向对象 正则表达式 知识概要: (1)正则表达式的特点 (2)正则表达的匹配 (3)正则表达式的切割,替换,获取 (4)正则表达式的练习 正则表达式:符合 ...
- commons-pool与commons-pool2连接池
commons-pool和commons-pool2是用来建立对象池的框架,提供了一些将对象池化必须要实现的接口和一些默认动作.对象池化之后可以通过pool的概念去管理其生命周期,例如对象的创建,使用 ...
- zookeeper curator选主(Leader)
在分布式系统设计中,选主是一个常见的场景.选主是一个这样的过程,通过选主,主节点被选择出来控制其他节点或者是分配任务. 选主算法要满足的几个特征: 1)各个节点均衡的获得成为主节点的权利,一旦主节点被 ...
- 【学习】滚动延迟加载插件scrollLoading用法
今天遇到一个很好用的滚动延迟加载的插件,作者是我的偶象大神张鑫旭,其博客为http://www.zhangxinxu.com/. 以前也写过这种效果,用的是lazyload,不过只能实现图片的加载.而 ...
- linux 计划任务(crontab)
每天写一点,总有一天我这条咸鱼能变得更咸 cron服务是一个linux下 的定时执行工具,可以在无需人工干预的情况下运行作业.频率可以划分为 分钟 小时 天 月 周,格式如下: 1.crontab 服 ...
- JavaScript--我发现,原来你是这样的JS(引用类型不简单,且听我娓娓道来)
一.介绍 没错,这是第五篇,到了引用类型,这次要分成两次博文了,太多内容了,这是前篇,篇幅很长也很多代码,主要讲引用类型和常用的引用类型,代码试验过的,老铁没毛病. 坚持看坚持写,不容易不容易,希望大 ...
- Bootstrap--下拉菜单.dropdown
下拉菜单.dropdown .dropdown <下拉菜单触发器button+下拉菜单ul> .dropdown 包裹层 .dropdown-toggle 下拉菜单触发器 data-to ...

