docs(v2): analytics (#1678)

* docs(v2): analytics

* docs(v2): rework analytics docs

* fix broken link
This commit is contained in:
Wei Gao 2019-07-23 14:31:59 +08:00 committed by GitHub
parent a684806a0f
commit f2864e0a91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 39 deletions

View file

@ -166,18 +166,55 @@ module.exports = {
### `@docusaurus/plugin-google-analytics`
The classic template ships with this plugin for Google Analytics. To use this analytics, specify the plugin in the `plugins` field, and provide your Google Analytics configuration in [theme config](./using-themes.md).
The default [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/) plugin.
**Installation**
```shell
$ yarn add @docusaurus/plugin-google-analytics
```
**Configuration**
```js
// docusaurus.config.js
module.exports = {
plugins: ['@docusaurus/plugin-google-analytics'],
plugins: [
[
'@docusaurus/plugin-google-analytics',
{
trackingID: 'UA-142857148-5',
},
],
],
};
```
### `@docusaurus/plugin-google-gtag`
_This section is a work in progress. [Welcoming PRs](https://github.com/facebook/docusaurus/issues/1640)._
The default [Global Site Tag (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs/) plugin.
**Installation**
```shell
$ yarn add @docusaurus/plugin-google-gtag
```
**Configuration**
```js
// docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-google-gtag',
{
trackingID: 'UA-142857148-5',
},
],
],
};
```
### `@docusaurus/plugin-sitemap`

47
website/docs/analytics.md Normal file
View file

@ -0,0 +1,47 @@
---
id: analytics
title: Analytics
keywords:
- docusaurus
- analytics
---
This page describes how to configure a Docusaurus site to enable Google's libraries and SDKs for tracking.
## `@docusaurus/plugin-google-analytics`
[Google's analytics.js library](https://developers.google.com/analytics/devguides/collection/analyticsjs/) is a JavaScript library for measuring how users interact with your website. This section explains how to configure a Docusaurus site to enable Google Analytics.
If you generalized your site using Docusaurus' classic template, ou may enable the analytics plugin directly by specifying the Google Analytics tracking id via the `themeConfig` field:
```js
// docusaurus.config.js
module.exports = {
themeConfig: {
googleAnalytics: {
trackingID: 'UA-142857148-5',
},
},
};
```
To learn how to manually set up the Google Analytics plugin for Docusaurus sites not generated from the classic template, refer to [Advanced Guides: Plugins `@docusaurus/plugin-google-analytics`](advanced-plugins.md#docusaurusplugin-google-analytics).
## `@docusaurus/plugin-google-gtag`
Google's [Global Site Tag (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs/) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. This section describes how to configure a Docusaurus site to enable global site tag for Google Analytics.
If you generalized your site using Docusaurus' classic template, ou may enable the gtag plugin directly by specifying the gtag tracking id via the `themeConfig` field:
```js
// docusaurus.config.js
module.exports = {
themeConfig: {
gtag: {
trackingID: 'UA-142857148-5',
},
},
};
```
To learn how to manually set up the gtag plugin for Docusaurus sites not generated from the classic template, refer to [Advanced Guides: Plugins `@docusaurus/plugin-google-gtag`](advanced-plugins.md#docusaurusplugin-google-gtag).

View file

@ -1,35 +0,0 @@
---
id: reaching-users
title: Reaching Users
keywords:
- docusaurus
- seo
- analytics
---
## Search
_This section is a work in progress. [Welcoming PRs](https://github.com/facebook/docusaurus/issues/1640)._
<!--
References
---
- [Docusaurus v1 search](https://docusaurus.io/docs/en/search)
- [Algolia documentation](https://www.algolia.com/doc/)
-->
## Analytics
_This section is a work in progress. [Welcoming PRs](https://github.com/facebook/docusaurus/issues/1640)._
<!--
Cover actual usage guidelines of adding analytics to sites.
References
---
- [source code](packages/docusaurus-plugin-google-analytics/src/index.js)
- [plugins](plugins.md)
-->

19
website/docs/search.md Normal file
View file

@ -0,0 +1,19 @@
---
id: search
title: Search
keywords:
- docusaurus
- search
---
## Search
_This section is a work in progress. [Welcoming PRs](https://github.com/facebook/docusaurus/issues/1640)._
<!--
References
---
- [Docusaurus v1 search](https://docusaurus.io/docs/en/search)
- [Algolia documentation](https://www.algolia.com/doc/)
-->

View file

@ -23,8 +23,9 @@ module.exports = {
items: ['markdown-features', 'sidebar'],
},
'blog',
'analytics',
'seo',
// 'reaching-users', // add back analytics and search
'search',
'using-plugins',
'using-themes',
'deployment',