Skip to content

Commit caa5491

Browse files
committed
docs(plugin-google-analytics): add plugin reference
1 parent dbc0da1 commit caa5491

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

Diff for: docs/reference/plugin/google-analytics.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# google-analytics
22

3-
> TODO
3+
> @vuepress/plugin-google-analytics
4+
5+
Integrate [Google Analytics](https://analytics.google.com/) into VuePress.
6+
7+
This plugin will import [gtag.js](https://developers.google.com/analytics/devguides/collection/gtagjs) for [Google Analytics 4](https://support.google.com/analytics/answer/10089681).
8+
9+
## Reporting Events
10+
11+
Google Analytics will [automatically collect some events](https://support.google.com/analytics/answer/9234069), such as `page_view`, `first_visit`, etc.
12+
13+
So if you only want to collect some basic data of your site, you don't need to do anything else except setting the [Measurement ID](#id) correctly.
14+
15+
After using this plugin, the global `gtag()` function is available on the `window` object, and you can use it for [custom events reporting](https://developers.google.com/analytics/devguides/collection/ga4/events).
16+
17+
## Options
18+
19+
### id
20+
21+
- Type: `string`
22+
23+
- Details:
24+
25+
The Measurement ID of Google Analytics 4, which should start with `'G-'`.
26+
27+
You can follow the instructions [here](https://support.google.com/analytics/answer/9539598) to find your Measurement ID. Notice the difference between Google Analytics 4 Measurement ID (i.e. "G-" ID) and Universal Analytics Tracking ID (i.e. "UA-" ID).
28+
29+
- Example:
30+
31+
```js
32+
module.exports = {
33+
plugins: [
34+
[
35+
'@vuepress/plugin-google-analytics',
36+
{
37+
id: 'G-XXXXXXXXXX',
38+
},
39+
],
40+
],
41+
}
42+
```

Diff for: docs/zh/reference/plugin/google-analytics.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# google-analytics
22

3-
> TODO
3+
> @vuepress/plugin-google-analytics
4+
5+
[Google Analytics](https://analytics.google.com/) 集成到 VuePress 中。
6+
7+
该插件会通过引入 [gtag.js](https://developers.google.com/analytics/devguides/collection/gtagjs) 来启用 [Google Analytics 4](https://support.google.com/analytics/answer/10089681)
8+
9+
## 上报事件
10+
11+
Google Analytics 会 [自动收集部分事件](https://support.google.com/analytics/answer/9234069) ,比如 `page_view`, `first_visit` 等。
12+
13+
因此,如果你只是想收集站点的一些基础数据,你只需要正确设置 [Measurement ID](#id) ,不需要再额外做其他事情。
14+
15+
在引入该插件之后,一个全局的 `gtag()` 函数会被挂载到 `window` 对象上,你可以使用它进行 [自定义事件的上报](https://developers.google.com/analytics/devguides/collection/ga4/events)
16+
17+
## 配置项
18+
19+
### id
20+
21+
- 类型: `string`
22+
23+
- 详情:
24+
25+
Google Analytics 4 的 Measurement ID ,应以 `'G-'` 开头。
26+
27+
你可以通过 [这里](https://support.google.com/analytics/answer/9539598) 的指引来找到你的 Measurement ID 。注意区分 Google Analytics 4 的 Measurement ID (即 "G-" 开头的 ID) 和 Universal Analytics 的 Tracking ID (即 "UA-" 开头的 ID)。
28+
29+
- 示例:
30+
31+
```js
32+
module.exports = {
33+
plugins: [
34+
[
35+
'@vuepress/plugin-google-analytics',
36+
{
37+
id: 'G-XXXXXXXXXX',
38+
},
39+
],
40+
],
41+
}
42+
```

0 commit comments

Comments
 (0)