Google Tag Manager Integration
- Source code: https://github.com/hashbite/consent-manager/tree/main/packages/integration-google-tag-manager
The Google Tag Manager integration uses the react-gtm-module
to manage and deploy marketing tags (such as tracking pixels or site analytics) on your React application.
Warning: Using Google Tag Manager can significantly increase your site's loading time, especially if numerous scripts are enabled through it. It can also reduce the control developers have over tracking and script management on their website. Use it responsibly and understand its impact on performance and privacy.
Title | Google Tag Manager |
ID | google-tag-manager |
Icon | |
Brand color | #246FDB |
Contrast color | #fff |
Description | We use Google Tag Manager to improve your browsing experience. |
Privacy policy | https://policies.google.com/privacy?hl=en-US |
WrapperComponent | ✅ |
Enabled by default | ⛔️ |
Configuration Options
- gtmId: Your Google Tag Manager ID
getGoogleTagManager
Function
The getGoogleTagManager
function provides access to the initialized instance of react-gtm-module
. This allows for the integration and management of Google Tag Manager functionalities within your application.
Example Usage
This example demonstrates how you might use the getGoogleTagManager
function to manage Google Tag Manager in your React application:
import { useEffect } from 'react';
import { getGoogleTagManager } from '@consent-manager/integration-google-tag-manager';
function App() {
useEffect(() => {
const GTM = getGoogleTagManager();
if (GTM) {
// Add your Google Tag Manager functionalities here
// GTM.dataLayer.push(...) or other GTM operations
}
}, []);
// Your application content
return (
// ...
);
}
export default App;