mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 11:18:24 +02:00
* POC: add trailingSlash option * integrate the preferFoldersOutput option of fork @slorber/static-site-generator-webpack-plugin * Fix broken links when using trailing slash => using md links is more reliable * fix TS issue * minor polish * fix doc page being sensitive to trailing slashes * Add tests for applyTrailingSlash * rename test files * extract and test applyRouteTrailingSlash * update snapshot * add trailing slash config to serve command * fix getSidebar() => still sensitive to trailing slash setting * never apply trailing slash to an anchor link * Add documentation for trailingSlash setting
34 lines
1,016 B
Markdown
34 lines
1,016 B
Markdown
---
|
|
id: plugin-google-analytics
|
|
title: '📦 plugin-google-analytics'
|
|
slug: '/api/plugins/@docusaurus/plugin-google-analytics'
|
|
---
|
|
|
|
The default [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/) plugin. It is a JavaScript library for measuring how users interact with your website **in the production build**. If you are using Google Analytics 4 you might need to consider using [plugin-google-gtag](./plugin-google-gtag.md) instead.
|
|
|
|
## Installation {#installation}
|
|
|
|
```bash npm2yarn
|
|
npm install --save @docusaurus/plugin-google-analytics
|
|
```
|
|
|
|
:::tip
|
|
|
|
If you have installed `@docusaurus/preset-classic`, you don't need to install it as a dependency.
|
|
|
|
:::
|
|
|
|
## Configuration {#configuration}
|
|
|
|
```js title="docusaurus.config.js"
|
|
module.exports = {
|
|
plugins: ['@docusaurus/plugin-google-analytics'],
|
|
themeConfig: {
|
|
googleAnalytics: {
|
|
trackingID: 'UA-141789564-1',
|
|
// Optional fields.
|
|
anonymizeIP: true, // Should IPs be anonymized?
|
|
},
|
|
},
|
|
};
|
|
```
|