1

我一直在尝试将 Mixpanel 集成到我的 Android 应用程序中。在跟踪事件等方面工作正常,但问题是所有事件都记录在报告中的单个客人下。mixpanel.identify()我在and上调用了 identify() mixpanel.getPeople().identify(),我的代码看起来像这样:

    MixpanelAPI mixpanel = MixpanelAPI.getInstance(this, MIXPANEL_TOKEN);
    MixpanelAPI.People people = mixpanel.getPeople();
    people.identify("666");
    people.set("first_name", "john");
    people.set("last_name", "smith");

    JSONObject props = new JSONObject();
    try {
        props.put("Gender", "Male");
        props.put("Plan", "Premium");
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }


    mixpanel.track("Plan selected", props);
    mixpanel.flush();       

无论该跟踪事件被发送多少次(即使我更改了标识的值并再次跟踪),所有事件都在一个随机的来宾名称下进行跟踪:Guest #74352

4

1 回答 1

5

如果您想将事件与活动提要中的用户名相关联,您需要使用$first_name$last_name(包括美元符号)作为属性。Android 库不支持直接在流报告中进行名称标记,但您也可以通过向mp_name_tag事件添加超级属性来获得名称。所以你可能想让你的代码看起来像这样:

MixpanelAPI mixpanel = MixpanelAPI.getInstance(this, MIXPANEL_TOKEN);
MixpanelAPI.People people = mixpanel.getPeople();

// Using the same id for events and people updates will let you
// see events in the people analytics activity feed.
mixpanel.identify("666"); 
people.identify("666");

// Add the dollar sign to the name properties
people.set("$first_name", "john");
people.set("$last_name", "smith");

JSONObject nameTag = new JSONObject();
try {
    // Set an "mp_name_tag" super property 
    // for Streams if you find it useful.
    nameTag.put("mp_name_tag", "john smith");
    mixpanel.registerSuperProperties(nameTag);
} catch(JSONException e) {
    e.printStackTrace();
}

JSONObject props = new JSONObject();
try {
    props.put("Gender", "Male");
    props.put("Plan", "Premium");
} catch (JSONException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

mixpanel.track("Plan selected", props);
mixpanel.flush(); 
于 2013-07-18T19:41:21.653 回答