Skip to main content

Google Tag Manager Integration

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.

TitleGoogle Tag Manager
IDgoogle-tag-manager
IconGoogle Tag Manager
Brand color#246FDB
Contrast color#fff
DescriptionWe use Google Tag Manager to improve your browsing experience.
Privacy policyhttps://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;