跳到主要内容
版本:Canary 🚧

📦 plugin-google-tag-manager

A plugin for adding Google Tag Manager (gtm.js) to a Docusaurus site. Use this plugin in conjunction with the standard gtag plugin for in-depth analysis of how users are using your site.

提示

You can use Google's Tag Assistant tool to check if tag manager is set up correctly!

production only

这个插件始终不会工作在开发过程中,只在生产环境中启用,防止污染分析数据。

安装流程

npm install --save @docusaurus/plugin-google-tag-manager
提示

如果你已经安装了 @docusaurus/preset-classic,就不需要安装这个包了。

You can configure this plugin through the preset options.

配置

接受的字段:

参数类型默认值描述
containerIdstring必填Your Tag Manager container Id (usually starts with GTM-).

示例配置

你可以通过预设选项或插件选项来配置这个插件。

提示

大多数 Docusaurus 用户通过预设选项配置此插件。

如果你使用预设,你可以通过预设选项配置这个插件:

docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
googleTagManager: {
containerId: 'GTM-12345',
},
},
],
],
};