From f2864e0a917fb257119c8cd4bbb3ce563ef8ec4f Mon Sep 17 00:00:00 2001 From: Wei Gao Date: Tue, 23 Jul 2019 14:31:59 +0800 Subject: [PATCH] docs(v2): analytics (#1678) * docs(v2): analytics * docs(v2): rework analytics docs * fix broken link --- website/docs/advanced-plugins.md | 43 +++++++++++++++++++++++++++-- website/docs/analytics.md | 47 ++++++++++++++++++++++++++++++++ website/docs/reaching-users.md | 35 ------------------------ website/docs/search.md | 19 +++++++++++++ website/sidebars.js | 3 +- 5 files changed, 108 insertions(+), 39 deletions(-) create mode 100644 website/docs/analytics.md delete mode 100644 website/docs/reaching-users.md create mode 100644 website/docs/search.md diff --git a/website/docs/advanced-plugins.md b/website/docs/advanced-plugins.md index 7c5345e1ee..ed840ad4e5 100644 --- a/website/docs/advanced-plugins.md +++ b/website/docs/advanced-plugins.md @@ -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` diff --git a/website/docs/analytics.md b/website/docs/analytics.md new file mode 100644 index 0000000000..e3d9a7daae --- /dev/null +++ b/website/docs/analytics.md @@ -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). diff --git a/website/docs/reaching-users.md b/website/docs/reaching-users.md deleted file mode 100644 index 28e4566d87..0000000000 --- a/website/docs/reaching-users.md +++ /dev/null @@ -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)._ - - - -## Analytics - -_This section is a work in progress. [Welcoming PRs](https://github.com/facebook/docusaurus/issues/1640)._ - - diff --git a/website/docs/search.md b/website/docs/search.md new file mode 100644 index 0000000000..5a6080f7f6 --- /dev/null +++ b/website/docs/search.md @@ -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)._ + + diff --git a/website/sidebars.js b/website/sidebars.js index 0d1676d5fa..edecdd3a4d 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -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',