Skip to content

Simple components adding Google Tag Manager to your React application

Notifications You must be signed in to change notification settings

Yankovsky/react-gtm-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

yarn add react-gtm-components

Usage

import { GtmScript, GtmNoScript } from 'react-gtm-components'

const gtmId = 'GTM-0000000'

<html>
	<head>
		<GtmScript gtmId={gtmId} />
		...
	</head>
	<body>
		<GtmNoScript gtmId={gtmId} />
		...
	</body>
</html>
import { GtmScript, GtmNoScript } from 'react-gtm-components'

const gtmId = 'GTM-0000000'
const gtmUrlParams = NODE_ENV === 'development' ? {
	gtm_auth: 'my_auth_key',
	gtm_preview: 'env-123',
} : {}

<html>
	<head>
		<GtmScript gtmId={gtmId} gtmUrlParams={gtmUrlParams} />
		...
	</head>
	<body>
		<GtmNoScript gtmId={gtmId} gtmUrlParams={gtmUrlParams} />
		...
	</body>
</html>

Examples/Tests

Check https://github.com/Yankovsky/react-gtm-components/blob/master/soon-to-be-test-folder/index.jsx

About

Simple components adding Google Tag Manager to your React application

Resources

Stars

Watchers

Forks

Packages

No packages published