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

家住魔仙堡 提交于 2020-01-01 10:16:26

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/23367237/how-do-i-track-user-ids-w-google-analytics-no-page-reload-after-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!