Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Google Analytics User ID after creating the tracker

Tags:

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?

like image 544
Eli White Avatar asked Apr 30 '14 03:04

Eli White


People also ask

Can Google Analytics track User-ID?

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.

How do I add a user to Google Tag Manager?

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.


1 Answers

This one works

ga('set', '&uid', '<dynamic user id here>'); 
like image 155
Eduardo Avatar answered Sep 18 '22 12:09

Eduardo