What is @docusaurus/plugin-google-tag-manager?
@docusaurus/plugin-google-tag-manager is a plugin for Docusaurus that allows you to integrate Google Tag Manager (GTM) into your Docusaurus site. This enables you to manage and deploy marketing tags (snippets of code or tracking pixels) on your website without modifying the codebase.
What are @docusaurus/plugin-google-tag-manager's main functionalities?
Basic Integration
This feature allows you to integrate Google Tag Manager into your Docusaurus site by adding the plugin to your Docusaurus configuration file. Replace 'GTM-XXXXXX' with your actual GTM container ID.
{
"plugins": [
[
"@docusaurus/plugin-google-tag-manager",
{
"gtm": "GTM-XXXXXX"
}
]
]
}
Custom Data Layer
This feature allows you to push custom data to the GTM data layer. You can specify additional data that you want to track, such as user ID or page category.
{
"plugins": [
[
"@docusaurus/plugin-google-tag-manager",
{
"gtm": "GTM-XXXXXX",
"dataLayer": {
"userId": "USER_ID",
"pageCategory": "CATEGORY"
}
}
]
]
}
Other packages similar to @docusaurus/plugin-google-tag-manager
react-gtm-module
react-gtm-module is a package for integrating Google Tag Manager with React applications. It provides a simple API to initialize GTM and push events to the data layer. Compared to @docusaurus/plugin-google-tag-manager, it is more general-purpose and can be used with any React application, not just Docusaurus.
gatsby-plugin-google-tagmanager
gatsby-plugin-google-tagmanager is a plugin for Gatsby that integrates Google Tag Manager into Gatsby sites. It offers similar functionality to @docusaurus/plugin-google-tag-manager but is specifically designed for Gatsby, another static site generator.