docs(v2): specify google-analytics and gtag plugins (#4703)

Closes #4678
This commit is contained in:
Ian Hornik 2021-05-04 16:46:07 +02:00 committed by GitHub
parent 86cab6111b
commit 5fc5071882
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -4,7 +4,7 @@ title: '📦 plugin-google-analytics'
slug: '/api/plugins/@docusaurus/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. 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) instead.
## Installation {#installation} ## Installation {#installation}

View file

@ -4,7 +4,13 @@ title: '📦 plugin-google-gtag'
slug: '/api/plugins/@docusaurus/plugin-google-gtag' slug: '/api/plugins/@docusaurus/plugin-google-gtag'
--- ---
The default [Global Site Tag (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs/) plugin. It 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. The default [Global Site Tag (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs/) plugin. It is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform, **in the production build**. This section describes how to configure a Docusaurus site to enable global site tag for Google Analytics.
:::tip
You can use [Google's Tag Assistant](https://tagassistant.google.com/) tool to check if your gtag is set up correctly!
:::
## Installation {#installation} ## Installation {#installation}
@ -25,6 +31,7 @@ module.exports = {
plugins: ['@docusaurus/plugin-google-gtag'], plugins: ['@docusaurus/plugin-google-gtag'],
themeConfig: { themeConfig: {
gtag: { gtag: {
// You can also use your "G-" Measurement ID here.
trackingID: 'UA-141789564-1', trackingID: 'UA-141789564-1',
// Optional fields. // Optional fields.
anonymizeIP: true, // Should IPs be anonymized? anonymizeIP: true, // Should IPs be anonymized?