📦 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
This plugin is always inactive in development and only active in production to avoid polluting the analytics statistics.
Installation
- npm
- Yarn
- pnpm
- Bun
npm install --save @docusaurus/plugin-google-tag-manager
yarn add @docusaurus/plugin-google-tag-manager
pnpm add @docusaurus/plugin-google-tag-manager
bun add @docusaurus/plugin-google-tag-manager
팁
If you use the preset @docusaurus/preset-classic
, you don't need to install this plugin as a dependency.
You can configure this plugin through the preset options.
Configuration
설정할 수 있는 필드
옵션명 | 타입 | 기본값 | 설명 |
---|---|---|---|
containerId | string | Required | Your Tag Manager container Id (usually starts with GTM- ). |
Example configuration
프리셋 옵션이나 플러그인 옵션에서 플러그인을 설정할 수 있습니다.
팁
대부분의 도큐사우루스 사용자는 프리셋 옵션을 사용해 플러그인을 설정합니다.
- 프리셋 옵션
- 플러그인 옵션
프리셋을 사용하는 경우 프리셋 옵션를 통해 플러그인을 구성합니다.
docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
googleTagManager: {
containerId: 'GTM-12345',
},
},
],
],
};
독립적으로 실행되는 플러그인을 사용하는 경우에는 플러그인에 대한 옵션을 직접 설정할 수 있습니다.
docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-google-tag-manager',
{
containerId: 'GTM-12345',
},
],
],
};