Google Analytics - Match UserID with my site's account ID

六月ゝ 毕业季﹏ 提交于 2019-12-09 01:42:56

问题


Each of my registered clients have an unique account ID (eg: agent n°: 00173393).

I want to retrieve this information through google analytics... It's not a personal information and for statistics use only.

I implemented userID, but how to match userID and the accounts IDs ?

Is it possible to create a variable for the account ID number ?


回答1:


Why don't you use the account ID as User ID as well? That way you would have a 1-to-1 match:

ga('create', 'UA-XXXXX-Y', 'auto', {
  userId: accountId
});

Please note however that the User ID is not exposed back by Google Analytics. If you want to retrieve it, you need to save it inside a custom dimension:

  • Admin -> Property -> Custom Dimensions -> Create one with User scope
  • Add custom dimension tracking to your code

For instance:

ga('create', 'UA-XXXXX-Y', 'auto', {
  userId: accountId,
});
ga('set', 'cd1', accountId); // if it's custom dimension n1
ga('send', 'pageview');

Then you can retrieve the User ID via the UI:

or the API



来源:https://stackoverflow.com/questions/48886764/google-analytics-match-userid-with-my-sites-account-id

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