Mixpanel 人员跟踪不起作用
Mixpanel people tracking not working
我正在尝试让 Mixpanel 人员跟踪工作但没有成功。我在日志中看到,发送了 create alias event
但在 Mixpanel 控制台中没有创建用户配置文件。
这也是我在其中成功复制问题的演示应用程序的代码,由于保密原因,我无法共享原始应用程序的代码。
class MainActivity : AppCompatActivity() {
lateinit var mixpanel: MixpanelAPI
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mixpanel = MixpanelAPI.getInstance(this, "mytoken")
mixpanel.people.set("open date", Date())
mixpanel.identify(mixpanel.distinctId)
setContentView(R.layout.activity_main)
initCustomer()
postToMixpanel("TEST EVENT")
MPLog.setLevel(MPLog.VERBOSE)
}
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
val map = listOfNotNull(
"$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
fun postToMixpanel(eventId: String, additionalProps: Map<String, Any>? = null) {
val props = JSONObject()
additionalProps?.let {
for ((key, value) in it) {
props.put(key, value)
}
}
mixpanel.track(eventId, props)
}
}
这些是来自创建别名事件的混合面板日志,我在其中看不到任何特殊的 属性,例如 $name
和 $email
。
[{
"event": "$create_alias",
"properties": {
"mp_lib": "android",
"$lib_version": "5.4.1",
"$os": "Android",
"$os_version": "8.1.0",
"$manufacturer": "UMIDIGI",
"$brand": "UMIDIGI",
"$model": "A1_PRO",
"$google_play_services": "available",
"$screen_dpi": 320,
"$screen_height": 1344,
"$screen_width": 720,
"$app_version": "1.007-staging",
"$app_version_string": "1.007-staging",
"$app_release": 15,
"$app_build_number": 15,
"$has_nfc": false,
"$has_telephone": true,
"$carrier": "m:tel",
"$wifi": true,
"$bluetooth_enabled": false,
"$bluetooth_version": "ble",
"token": "",
"Has Credit": "False",
"Amount of Credits": "0",
"time": 1530099794,
"distinct_id": "b8769eeb-6a3b-4692-8973-261f9933537e",
"alias": "260",
"original": "b8769eeb-6a3b-4692-8973-261f9933537e"
},
"$mp_metadata": {
"$mp_event_id": "43f9c3402ffa6f4c",
"$mp_session_id": "c35a49a17d3b9de6",
"$mp_session_seq_id": 0,
"$mp_session_start_sec": 1530099793
}
}]
尝试对人员对象调用 identify() 方法。它应该在 Mixpanel 中创建一个用户。
mixpanel.people.identify(mixpanel.getDistinctId());
之后
mixpanel.alias("1", mixpanel.distinctId)
在你有趣的 initCustomer()
方法中。
示例:
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
mixpanel.people.identify(mixpanel.getDistinctId());
val map = listOfNotNull(
"$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
android 文档中的更多信息:管理用户身份
我正在尝试让 Mixpanel 人员跟踪工作但没有成功。我在日志中看到,发送了 create alias event
但在 Mixpanel 控制台中没有创建用户配置文件。
这也是我在其中成功复制问题的演示应用程序的代码,由于保密原因,我无法共享原始应用程序的代码。
class MainActivity : AppCompatActivity() {
lateinit var mixpanel: MixpanelAPI
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mixpanel = MixpanelAPI.getInstance(this, "mytoken")
mixpanel.people.set("open date", Date())
mixpanel.identify(mixpanel.distinctId)
setContentView(R.layout.activity_main)
initCustomer()
postToMixpanel("TEST EVENT")
MPLog.setLevel(MPLog.VERBOSE)
}
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
val map = listOfNotNull(
"$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
fun postToMixpanel(eventId: String, additionalProps: Map<String, Any>? = null) {
val props = JSONObject()
additionalProps?.let {
for ((key, value) in it) {
props.put(key, value)
}
}
mixpanel.track(eventId, props)
}
}
这些是来自创建别名事件的混合面板日志,我在其中看不到任何特殊的 属性,例如 $name
和 $email
。
[{ "event": "$create_alias", "properties": { "mp_lib": "android", "$lib_version": "5.4.1", "$os": "Android", "$os_version": "8.1.0", "$manufacturer": "UMIDIGI", "$brand": "UMIDIGI", "$model": "A1_PRO", "$google_play_services": "available", "$screen_dpi": 320, "$screen_height": 1344, "$screen_width": 720, "$app_version": "1.007-staging", "$app_version_string": "1.007-staging", "$app_release": 15, "$app_build_number": 15, "$has_nfc": false, "$has_telephone": true, "$carrier": "m:tel", "$wifi": true, "$bluetooth_enabled": false, "$bluetooth_version": "ble", "token": "", "Has Credit": "False", "Amount of Credits": "0", "time": 1530099794, "distinct_id": "b8769eeb-6a3b-4692-8973-261f9933537e", "alias": "260", "original": "b8769eeb-6a3b-4692-8973-261f9933537e" }, "$mp_metadata": { "$mp_event_id": "43f9c3402ffa6f4c", "$mp_session_id": "c35a49a17d3b9de6", "$mp_session_seq_id": 0, "$mp_session_start_sec": 1530099793 } }]
尝试对人员对象调用 identify() 方法。它应该在 Mixpanel 中创建一个用户。
mixpanel.people.identify(mixpanel.getDistinctId());
之后
mixpanel.alias("1", mixpanel.distinctId)
在你有趣的 initCustomer()
方法中。
示例:
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
mixpanel.people.identify(mixpanel.getDistinctId());
val map = listOfNotNull(
"$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
android 文档中的更多信息:管理用户身份