I am working on a next project, and from the \_app.tsx file, I am pushing this dummy data to the dataLayer of google tag manager
<Script id="gtm" strategy="beforeInteractive"> {
window.dataLayer = window.dataLayer || \[\];
window.dataLayer.push({event: 'test', 'userId': 'abc098'});
}</Script>
The objective I am trying to attain is that when I pass this userId to dataLayer in google tag manager; I want to be able to view this under Google Analytics -> Explore -> User Explorer Section
In google tag manager, I have done the following steps:
- Created a variable with the name
'userId'(just as in mydataLayer) - Then in my GA4 tag as you can see in the image I have attached below, under fields to set, I have added a field for :
user_idalong with the variable I created- setting
debug_modewith value 'true' - Under Property Name: I have added
user_id_dimensionwith theuserIdvariable GA4 Tag Configuration
- Under triggers, I have created a custom event with the name 'test', referenced under my GA4 tag Trigger Configuration
In google analytics:
- For web data streams - I have enhanced measurement on
- Also created a custom definition for userId with
user_id_dimensionas created under property in gtm
When I preview my website on GTM; I am able to see that my test event is being pushed to dataLayer along with the userId, and my GA4 tag is also being fired.
But on Google Analytics, I am not able to see the userId in events or in the User Explorer section
I also have all my changes submitted on GTM.