Correct code to track user ID?
-
Hi. I want to track logged-in users on my site. I went through the steps on the Google Analytics side to enable it. I checked the “Track User ID” box on the Advanced tab of Analytify. Is that all I need to do?
After doing that, I checked the GA code on the page and there was no code added after enabling Track User ID and reloading the page. So I added the following code in the Custom JS Code box at the bottom of the Advanced tab of Analytify:
ga(‘set’, ‘userId’, ‘USER_ID’);
I copied that from GA. I’m not sure that this code will automatically insert the current user’s ID and send it to GA though. I reloaded the web page and that code is there, but I think it’s just the string “USER_ID” that will be sent, and not the actual user ID. Am I right? How do I fix that?
Thanks so much,
John
The topic ‘Correct code to track user ID?’ is closed to new replies.