# 📦 plugin-google-gtag

The default [Global Site Tag (gtag.js)](https://developers.google.com/tag-platform/gtagjs) plugin. It is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. This section describes how to configure a Docusaurus site to enable global site tag for Google Analytics.

:::callout{intent="tip"}
You can use [Google's Tag Assistant](https://tagassistant.google.com/) tool to check if your gtag is set up correctly!
:::

:::callout{intent="warning" title="production only"}
This plugin is always inactive in development and **only active in production** to avoid polluting the analytics statistics.
:::

## Installation

```bash npm2yarn
npm install --save @docusaurus/plugin-google-gtag
```

:::callout{intent="tip"}
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](/guides/using-plugins#docusauruspreset-classic).
:::

## Configuration

Accepted fields:

```mdx-code-block
<APITable>
```

| Name          | Type                 | Default      | Description                                                                   |
| ------------- | -------------------- | ------------ | ----------------------------------------------------------------------------- |
| `trackingID`  | `string \| string[]` | **Required** | The tracking ID of your gtag service. It is possible to provide multiple ids. |
| `anonymizeIP` | `boolean`            | `false`      | Whether the IP should be anonymized when sending requests.                    |

```mdx-code-block
</APITable>
```

### Example configuration

You can configure this plugin through preset options or plugin options.

:::callout{intent="tip"}
Most Docusaurus users configure this plugin through the preset options.
:::

```js config-tabs
// Preset Options: gtag
// Plugin Options: @docusaurus/plugin-google-gtag

const config = {
  trackingID: 'G-999X9XX9XX',
  anonymizeIP: true,
};
```

## Related pages

- [Docusaurus plugins](./api-plugins-overview.md)
- [📦 plugin-content-docs](./api-plugins-plugin-content-docs.md)
- [📦 plugin-content-blog](./api-plugins-plugin-content-blog.md)
- [📦 plugin-content-pages](./api-plugins-plugin-content-pages.md)
- [📦 plugin-client-redirects](./api-plugins-plugin-client-redirects.md)
- [📦 plugin-debug](./api-plugins-plugin-debug.md)
- [📦 plugin-rsdoctor](./api-plugins-plugin-rsdoctor.md)
- [📦 plugin-svgr](./api-plugins-plugin-svgr.md)
- [📦 plugin-google-tag-manager](./api-plugins-plugin-google-tag-manager.md)
- [📦 plugin-ideal-image](./api-plugins-plugin-ideal-image.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
