The Google Analytics User ID documentation page shows that you set the User ID when you create the tracker. I have a javascript only project with sign-in after page load, is there any way to set the User ID after login? Something like ga("set", "userid", "UNIQUEID")
On the field reference page it says you can only set user-id in the create function. Are we able to call create again with the user-id? Will that create a new tracker, or override the old one?
EDIT: The beta version of User ID tracking showed that you could specify the userid after creating the tracker using ga('set', '&uid', {{ USER_ID }});
and that would try to unify the session from before the userid was set with the one after. That seems to be very different than what the docs current specify. Is there any way to do this with the current method?
With Google Analytics User ID tracking, you have access to that data. Google Analytics sets a cookie whenever a user enters your website and assigns them with an unique anonymous ID. So, if you go to Audience > User Explorer, you can see a list of anonymous IDs that Analytics assigns to your website visitors.
Once you have created a dataLayer variable, enable User ID tracking in your Google Analytics account: Navigate to Admin in the Google Analytics property for which you'd like to set up User ID tracking. Navigate to User-ID tracking through Admin > Property > Tracking Info > User-ID.
This one works
ga('set', '&uid', '<dynamic user id here>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With