📦 plugin-google-gtag
The default Global Site Tag (gtag.js) plugin. 여러분이 구글 애널리틱스, 구글 광고, 구글 마케팅 플랫폼에 이벤트 데이터를 보낼 수 있게 하는 자바스크립트 태킹 프레임워크와 API입니다. 여기에서는 구글 애널리틱스를 위한 전역 사이트 태그를 활성화하기 위해 도큐사우루트 사이트 설정을 어떻게 해야 하는지 설명합니다.
팁
You can use Google's Tag Assistant tool to check if your gtag 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-gtag
yarn add @docusaurus/plugin-google-gtag
pnpm add @docusaurus/plugin-google-gtag
bun add @docusaurus/plugin-google-gtag
팁
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
설정할 수 있는 필드
옵션명 | 타입 | 기본값 | 설명 |
---|---|---|---|
trackingID | string | string[] | Required | gtag 서비스의 추적 ID 여러 개의 ID를 사용할 수 있습니다. |
anonymizeIP | boolean | false | 요청을 보낼 때 IP를 익명화할지 여부 |
Example configuration
프리셋 옵션이나 플러그인 옵션에서 플러그인을 설정할 수 있습니다.
팁
대부분의 도큐사우루스 사용자는 프리셋 옵션을 사용해 플러그인을 설정합니다.
- 프리셋 옵션
- 플러그인 옵션
프리셋을 사용하는 경우 프리셋 옵션를 통해 플러그인을 구성합니다.
docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
gtag: {
trackingID: 'G-999X9XX9XX',
anonymizeIP: true,
},
},
],
],
};
독립적으로 실행되는 플러그인을 사용하는 경우에는 플러그인에 대한 옵션을 직접 설정할 수 있습니다.
docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-google-gtag',
{
trackingID: 'G-999X9XX9XX',
anonymizeIP: true,
},
],
],
};