识别登录前发生的 Mixpanel 用户操作

Identify Mixpanel user actions that occured before login

我遇到了 Mixpanel 识别问题。我希望能够跟踪用户登录前记录的事件并识别它们。

举个例子。 Louie 打开网页并访问“关于”页面。使用 mixpanel.track('Visit About'),我可以记录 Louie 的匿名访问。一切都很好,花花公子。

Louie 决定登录,mixpanel.identify(user.id) 调用确定了他的身份——随后的事件可以追溯到 Louie。然而,第一个事件(“Visit About”)仍然显示随机的、Mixpanel 设置的不同 ID,并且没有与 Louie 相关联。

这种行为是预期的吗?我能做什么?干杯

你想要alias.

来自他们的Javascript API reference

Use alias() when a unique ID is first assigned (registration), and use identify() to identify the user with that unique ID on an ongoing basis (e.g., each time a user logs in after registering). Do not call identify() at the same time as alias().

根据您的描述,Louie 不是匿名查看 "About" 页面然后 登录 ,而是匿名查看 "About" 页面然后注册

在这种情况下,在 Louie 注册时调用 alias,然后在他登录时调用 identify。这应该将随机的匿名 Mixpanel ID 与 Louie 的新注册用户 ID 相关联。

注意:使用此方法意味着,因为 Louie 匿名触发了一个事件,然后 登录了 ,Louie 在该事件中的匿名 ID 将不会链接到他来自登录。如果他在触发匿名事件后注册,您将调用alias,他们将被链接。不幸的是,这是 Mixpanel 的已知限制。来自他们的文档:

This is the first time he's accessed your site from this device, so we assign a brand new distinct_id to him. He clicks around and then logs in. You should not call mixpanel.alias() in this situation - we haven't seen him on this device, but he is not a new user. ... Instead of calling mixpanel.alias() you should just call mixpanel.identify(). This will remap his phone activity to the original ID he used when signing up for your service, which is the most desirable outcome. This does mean that regrettably the events he fired before logging in will not be associated with him.

更多关于 Mixpanel 中的别名 here

Alias 不适用于现有用户登录的情况,但我找到了解决方法。

当用户首次登录时,检查请求 cookie 的 distinct_id 是否与用户 ID 匹配。

如果不匹配,创建后端任务将匿名 distinct_Id 回填到用户的 distinct_id。

使用 JQL 加载事件,然后使用混合面板导入端点再次触发它们。

缺点是系统中会有重复的事件,因为无法从匿名 distinct_id 中删除事件。

对于导入的事件,您可以向它们添加一个 属性 表示它们是导入的,以便在需要时过滤掉它们。

他们花了一些时间,但在这里...

它叫做 Mixpanel Identity merge,它应该可以解决连接匿名用户在注册/登录之前所做的操作的整个问题

The new system improves the behavior of identify(), alias(), and adds a new event called $merge.
All pre-authentication activity can now be mapped back to a user The ID merge system makes it possible to link pre and post authenticated event streams under a single identifier. This eliminates “false-uniques”, ensuring the most accurate conversion and drop-off rates in funnels and flows. Previously, Mixpanel could only map pre-sign up activity back to a user who was later identified. Any activity a user did anonymously before signing in again could not be attributed to that user.

这里是全文blog post