Google Tags
You can use Google tags to track how users are using your website.
plugin-google-gtag
plugin-google-gtag
allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. To begin with:
Go to Google Tag Assistant, click Add domain, and input your website's URL. After this, you will obtain your
trackingID
formatted asG-xxxxxxxxxx
.Go to your project's root and run
yarn add @docusaurus/plugin-google-gtag
to install the plugin-google-gtag plugin.Configure the plugin in your
docusaurus.config.js
file as follows (replaceG-999X9XX9XX
with the value you obtained from Step 1):module.exports = {
plugins: [
[
'@docusaurus/plugin-google-gtag',
{
trackingID: 'G-999X9XX9XX',
anonymizeIP: true,
},
],
],
};
plugin-google-tag-manager
You can use this plugin in conjunction with gtag for in-depth analysis of how users are using your site.
Go to Google Tag Assistant, click Add domain, and input your website's URL. After this, you will obtain your
containerId
formatted asGTM-xxxxx
.Go to your project's root and run
yarn add @docusaurus/plugin-google-tag-manager
to install the plugin-google-tag-manager plugin.Configure the plugin in your
docusaurus.config.js
file as follows (replaceGTM-12345
with the value you obtained from Step 1):module.exports = {
plugins: [
[
'@docusaurus/plugin-google-tag-manager',
{
containerId: 'GTM-12345',
},
],
],
};
These two plugins are only active in production.