In my React SPA, I use npm module react-gtm-module to connect it to GTM. I can send events, using this syntax:
window.dataLayer.push({
event: 'calc_price_btn'
})
but I am not sure if and how I can send consent updates. Is it possible with this module, or will I have to use the standard gtag HTML snippet? Can react-gtm-module
do everything that standard gtag()
calls can?
What I was missing was defining the gtag()
function:
window.gtag = function(){
window.dataLayer.push(arguments)
}
It confused me that the Google documentation did not include the dataLayer.push()
calls—only the gtag()
calls. After defining the function, the code snippets from the docs can be used right away.