So after going through this over and over a bunch of times I realized cause of the issue.
Our application is a mix of an SPA with server side rendered pages. In our router for the front end I was doing this
let path = SomeRouter.currentPath
gtag('config', gaTrackingCode, {page_path: path})
The issue was that I was not passing in custom_map
into the configuration again when sending the page view
Every time you call gtag('config', gaTrackingCode, configParameters)
you need to resend the custom_map
in the configParamters
if you are setting custom dimensions and metrics.
Therefore the I changed the code to look like this
let path = SomeRouter.currentPath
gtag('config', gaTrackingCode,
{
page_path: path,
custom_map: {
'dimension1': 'user_type'
'dimension2': 'organization_id'
}
})
Now when I send an event, regardless if the route has changed, the custom dimensions are sent to google analytics.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…