Google Tag Manager plugin for analytics
Note: This package has moved to @analytics/google-tag-manager
Integration with google tag manager for analytics
For more information see the docs.
Usage
Install analytics
and @analytics/google-tag-manager
packages
npm install analytics @analytics/google-tag-manager
Import and initialize in project
import Analytics from 'analytics'
import googleTagManager from '@analytics/google-tag-manager'
const analytics = Analytics({
app: 'awesome-app',
plugins: [
googleTagManager({
containerId: 'GTM-123xyz',
})
]
})
analytics.page()
analytics.track('buttonClicked')
analytics.identify('user-xzy-123', {
name: 'Bill Murray',
cool: true
})
Configure Google Tag Manager
Make sure you have your google tags manager setup to fire on Page views.
If you are using a SPA you want to listen to history changes as well.
Plugin Options
Arguments
- pluginConfig
object
- Plugin settings - pluginConfig.containerId
string
- The Container ID uniquely identifies the GTM Container.
Example
googleTagManager({
containerId: 'GTM-123xyz'
})
See the full list of analytics provider plugins in the main repo.