instapage 上的 Mixpanel:mixpanel.people.set 不工作

Mixpanel on instapage : mixpanel.people.set not working

我正在结合使用 Mixpanel 和 Instapage。我的目标是 link 一个电子邮件地址给用户。

据我所知: 1)用户来到我的网站并获得一个独特的ID 2) 我需要打 1 次电话 mixpanel.alias + mixpanel.identify 3)我link变量给用户使用mixpanel.people.set

我添加了 mixpanel 片段和这个脚本,但它不起作用。知道为什么吗?

谢谢

<script type="text/javascript">
$('#myForm').submit(function() {
    var email = document.getElementById('4b8da538419309e7319a12be231f7456-1');
});


mixpanel.alias('email')
mixpanel.identify('email');
mixpanel.people.set({
"$email": email
});

</Script>

作为参考:https://mixpanel.com/help/reference/creating-a-profile

编辑:工作代码:

$('form.email-form').submit(function() {
    mixpanel.identify($('#REPLACE_WITH_ID').val());
    mixpanel.people.set({
         "$email" : $('#REPLACE_WITH_ID').val()
    });
});

如果需要添加别名(我不需要它)。

首先确保在执行上面的脚本之前添加了 mixpanel 库。您可以通过控制台记录 mixpanel 对象来检查。 console.log(mixpanel) 第二件事是你在上面的代码中做错了。

    $('#myForm').submit(function() {
        var email = document.getElementById('4b8da538419309e7319a12be231f7456-1');
        mixpanel.alias(email);
        mixpanel.identify(email); // or you can also do mixpanel.identify() only;
        mixpanel.people.set({
            "$email": email
        });
    });