You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mixpanel调试:查询拥有多个distinct ID的用户JQL语句

Mixpanel JQL查询:找出拥有多个Distinct ID的用户

你的现有JQL逻辑有误——这段代码是统计每个distinct_id的事件发生次数,而非找出同一个用户关联的多个distinct_id,完全无法满足调试用户错误合并的需求。

以下是两种符合需求的JQL查询方案:

方案1:全量查找拥有多个Distinct ID的用户

直接从Mixpanel的用户档案(People)中筛选,适合排查所有历史上出现多ID的用户:

function main() {
  return People()
    // 筛选拥有2个及以上distinct_id的用户
    .filter(profile => profile.$distinct_ids && profile.$distinct_ids.length > 1)
    .map(profile => ({
      user_id: profile.$user_id || "匿名用户",
      all_distinct_ids: profile.$distinct_ids,
      id_count: profile.$distinct_ids.length,
      last_active_time: profile.$last_seen
    }));
}

方案2:仅查找指定时间范围内有活动的多ID用户

结合事件数据,只排查你指定时间段内有行为的用户,更精准定位近期的错误合并问题:

function main() {
  // 先获取指定时间内有事件发生的所有distinct_id
  const activeDistinctIds = Events({
    from_date: "2024-08-01",
    to_date: "2024-08-08"
  })
  .groupBy(["distinct_id"], mixpanel.reducer.count())
  .keys();

  return People()
    .filter(profile => {
      // 筛选条件:有多个distinct_id,且至少一个ID在指定时间有活动
      const hasActiveId = profile.$distinct_ids?.some(id => activeDistinctIds.includes(id));
      return profile.$distinct_ids && profile.$distinct_ids.length > 1 && hasActiveId;
    })
    .map(profile => ({
      user_id: profile.$user_id || "匿名用户",
      all_distinct_ids: profile.$distinct_ids,
      id_count: profile.$distinct_ids.length,
      last_active_time: profile.$last_seen
    }));
}

自定义调整说明

  • 若要查找拥有X个及以上distinct_id的用户,只需将代码中的length > 1改为length >= X即可;
  • 返回结果包含用户ID(匿名用户会标注)、所有关联的distinct_id、ID数量、最后活跃时间,方便你对应到Mixpanel用户仪表盘逐一排查错误合并情况。

内容的提问来源于stack exchange,提问作者Michael

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 00:58:23