在 Google Analytics 中跟踪维度中的用户 ID

Track User ID in dimension in Google Analytics

我将 UserName 存储为 UserId,例如: ga('create', 'UA-XXXXXXX', { @if (Request.IsAuthenticated){@Html.Raw("'userId': '" + User.Identity.Name + "' ");} });

在我的 asp.net mvc 网站中: www.persiangulfcup.org

但我无法监控特定用户名和跟踪 his/her 操作。

这里有两个非常重要的事情需要注意:

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:

  1. Non-personally identifiable
  2. Unique to a user of your service or app
  3. Persistent for a signed-in user across all devices
  1. 无法在 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 相同的值。