我将 UserName 存储为 UserId,如下所示: ga('create', 'UA-XXXXXXX', { @if (Request.IsAuthenticated){@Html.Raw("'userId': '"+ User.Identity.Name + "'");} });
在我的 asp.net mvc 网站中: www.persiangulfcup.org
但我无法监控特定的用户名并跟踪他/她的操作。
最佳答案
这里有两件非常重要的事情需要注意:
1) 用户 ID不得包含任何个人身份信息。因此,就您而言,使用该人的姓名违反了使用条款,您的帐户可能会面临被关闭的风险:
It is up to you to provide the ID. These IDs typically come from an authentication system, in which each signed-in user account has a stable, and unique ID with which it is associated, and should have the following characteristics:
- Non-personally identifiable
- Unique to a user of your service or app
- Persistent for a signed-in user across all devices
- 无法在 API 或 Web 界面中查询用户 ID:
The User ID value can not be queried as a dimension in reports in either the web interface or the APIs.
来源: https://developers.google.com/analytics/devguides/platform/user-id
如果您想根据用户 ID 运行查询,则必须创建自定义维度并将其设置为与用户 ID 相同的值。
关于javascript - 在 Google Analytics 中跟踪维度中的用户 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29882424/