Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I track User IDs w/Google Analytics & no page reload after login?

We have an angular project that we want to track User IDs with Google Analytics.

The problem is, when the user is logged out & first loads the site, we have the create call pass "auto"

ga('create', 'UA-XXXX-Y', 'auto');

https://developers.google.com/analytics/devguides/collection/analyticsjs/

When the user logs in, there is no page load. Is it a problem to call the "create" event again with the User ID, or is there a better way to do this?

ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });

https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id

like image 473
poops Avatar asked Apr 29 '14 14:04

poops


People also ask

How do I track registered users in Google Analytics?

See Active Users dataSign in to Google Analytics. Navigate to your view. Open Reports. Select Audience > Active Users.


1 Answers

You can use the set method if the user logs in after page load

ga('set', 'userId', 'USERID'); 

https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#user

like image 194
Diego Rodríguez Avatar answered Oct 11 '22 17:10

Diego Rodríguez