Skip to main content

📦 plugin-google-gtag

The default Global Site Tag (gtag.js) plugin. これは、Googleアナリティクス、Google広告、および Googleマーケティングプラットフォームにイベントデータを送信できるJavaScriptタグ付けフレームワークおよび API です。 このセクションでは、Google Analytics のグローバルサイトタグ (gtag. js) を有効にする方法を説明します。

ヒント

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.

インストール

npm install --save @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.

設定

Accepted fields:

名前TypeDefault説明
trackingIDstring | string[]Requiredgtagサービスの追跡ID。 複数のIDを与えることも可能です。
anonymizeIPbooleanfalseリクエストを送信するときにIPを匿名化するかどうか。

Example configuration

このプラグインは、プリセットオプションまたはプラグインオプションを通じて設定できます。

ヒント

Most Docusaurus users configure this plugin through the preset options.

プリセットを使用する場合は、 設定オプション を介してこのプラグインを設定してください。

docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
gtag: {
trackingID: 'G-999X9XX9XX',
anonymizeIP: true,
},
},
],
],
};