In my react app I used react-gtm-module. and I have GTM ID only.
I put the below code in each page router component
import TagManager from 'react-gtm-module';
componentDidMount(){
const tagManagerArgs = {
dataLayer: {
page: '/pagepath'
},
gtmId: 'GTM-XXXXXX',
}
TagManager.initialize(tagManagerArgs)
}
I just put the above code in each route component. By using the above code, in google analytics sometimes the path shows and sometimes not showing in Active Page.
Is it only code I have to put in my code to achieve google analytics track pages or I have to add more else? If yes then exactly what I have to add and where to add?
Definitely, I miss something in my code. But what exactly?