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

标签 javascript asp.net-mvc google-analytics

我将 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:

  1. Non-personally identifiable
  2. Unique to a user of your service or app
  3. 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/

    相关文章:

    javascript - 谷歌 Ajax 搜索 API

    javascript - 关于 jQuery 模式的问题

    javascript - 当单击“后退”按钮查看文档时,如何强制 Web 浏览器重新加载文档?

    javascript - 当我有一个隐藏字段(如果选择一个选项时会显示该字段)时,我无法获取选择元素的值

    javascript - 如何使用 MVC TextBox 助手显示名称和 POST 值?

    ASP.NET MVC : Exception rendering view in new thread

    javascript - sendHitTask 不适用于通过 GTM Universal Analytics 标记模板发送的点击

    javascript - Elasticsearch : Javascript how to search with file template

    asp.net-mvc - 从另一个 ActionResult 返回一个 ActionResult

    javascript - 您可以将多个跟踪代码放在一个脚本标记中吗?