mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
docs(v2): analytics (#1678)
* docs(v2): analytics * docs(v2): rework analytics docs * fix broken link
This commit is contained in:
parent
a684806a0f
commit
f2864e0a91
5 changed files with 108 additions and 39 deletions
47
website/docs/analytics.md
Normal file
47
website/docs/analytics.md
Normal 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).
|
Loading…
Add table
Add a link
Reference in a new issue