Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Implementing User IDs in GTM and GA4 › Reply To: Implementing User IDs in GTM and GA4
-
To get a new userId everytime a user logs in, you need to replace the ‘1234567’ in your code with a variable that retrieves the userId from your system. This will differ based on your setup, but it’s often something like ‘window.user.id’ or ‘session.user.id’, where ‘user’ is the logged in user data and ‘id’ is their unique identifier. Basically, this variable should point to where your system keeps track of the logged-in user’s ID. Once this is setup, everytime a user logs in, the correct ID will be sent to Google Tag Manager.