【问题标题】:Google Analytics Universal Custom Dimension not tracking properlyGoogle Analytics(分析)通用自定义维度未正确跟踪
【发布时间】:2024-05-29 13:35:02
【问题描述】:

我们目前正在尝试将我们的用户数据库与来自 Google Analytics 的信息进行匹配,并且我们希望将他们的用户 ID 推送到 GA,以便我们可以检索有关我们用户的数据。

我们目前正在使用此代码,但似乎无法正确获取具有此新 user_id 自定义维度的报告。

<script>
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date(); a = s.createElement(o),
        m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

    ga('create', 'UA-xxxxx-1', 'auto');
    ga('require', 'displayfeatures');

    var dimensionValue = 'xxxxx'; //contains the user id
    ga('set', 'user_id', dimensionValue);

    ga('send', 'pageview');
</script>

Here is how it's setup on Google Analytics

And here is currently what we can see on Google Analytics

“74”这个值肯定是不对的,也不知道从哪里来的。

或者,我们希望将我们的用户 ID 与他们的获取来源(他们在到达我们的网站时最初来自哪里)相匹配,所以我想我们需要做一些类似“会话统一”的事情。但是,Google Analytics Universal 的内置 User-Id 功能似乎不允许检索实际的 user-id 值。

如果我们有任何方法可以做到这一点,我们愿意接受建议。如果您有实施此操作的经验或知道我们应该研究什么解决方案,我们将不胜感激。

谢谢。

【问题讨论】:

  • 你没有显示维度#,你需要使用“维度#”代替集合中的user_id。
  • 所以我们必须使用维度索引而不是维度实际名称
  • 是的,文档示例是ga('set', 'dimension5', 'custom data');

标签: javascript google-analytics user-tracking


【解决方案1】:

要将其设置为 custom dimension,您需要使用 dimension# 而不是您在 Google Analytics(分析)帐户中为维度指定的名称。

例如:

var dimensionValue = 'xxxxx'; //contains the user id
ga('set', 'dimension1', dimensionValue);

当您将其设置为自定义维度而不是使用 UserId feature 时,您无需担心丢失来源归属的问题。 (出于这个原因,我还使用自定义维度而不是 UserId 功能。)

【讨论】: