神策埋点-WEBH5到小程序匿名ID关联

321 阅读1分钟

需求:

H5投放落地页游客浏览=》到打开小程序进行购买,H5未登陆的情况下生成的匿名Id和小程序的用户ID进行关联

H5:脚本生成匿名ID 使用神策自定义,需要在sensors.login之前自定义,如果已经sensors.login使用sensors.logout() 切换为匿名ID

manual.sensorsdata.cn/sa/latest/s…

自定义匿名 ID
sensors.logout()
let tourist_id = Guid.NewGuid().ToString('D'); //前端脚本 可以是后短生成
sensors.identify(tourist_id, true)
sensors.login(user_id);

通过接口 把匿名ID传递给小程序

小程序:接口获取自定义的匿名ID,因为是api获取所以再获取小程序可能已经sensors.login因此处理方法同H5 也是先需要切换为匿名ID

自定义匿名 ID
sensors.logout()
let tourist_id = tourist_id //接口获取的
sensors.identify(tourist_id, true)
sensors.login(user_id);

⚠️注意:如果使用sensors.identify自定义匿名ID之前 看是否已经 sensors.login 已经绑定必须使用 sensors.logout()切换为匿名ID然乎在进行sensors.identify自定义,在进行sensors.login 这样匿名ID的行为才会和小程序的用户Id关联 相应的匿名ID的行为会和小程序的行为 进行关联