E企盈营销工具技术服务商 热线:4006-838-530

微信小程序获取用户的操作轨迹日新华区E企盈小程序志

q群: 581478349  花费了两天时间,修改过数次,终于把这个功能封装成了一个独立的工具。任何小程序都可在不修改原代码的情况下直接镶入使用!!!步骤:1. 在小程序 app.js 的平级目录创建一个 js , 命名为 userTrajectory.js。点击下载 userTrajectory.js 实现的代码是把 ‘存储用户在当前小程序的操作日志。然后传给后端’ 封装起来。2.在 app.js 内引用 userTrajectory.js ,并且把当前对象赋值给 userTrajectory.js 。示例代码:var userTrajectory = require(‘./userTrajectory.js’); App({  onLaunch: function(options) {    //获取用户操作轨迹    userTrajectory.initUserTrajectory.apply(this, []);  }})

3.在小程序内调用它。使用代码示例: Page({  data: {  },  onLoad: function (options) {    //opType = '操作类型', opEvent = '操作事件',opEventId = '操作事件ID',opnEventDetail = '操作事件详情'    getApp().getUserTrajectory(1, 'onLoad', 'pages/index_0', '进入小程序首页');//获取用户轨迹  }})

4.完成。用户操作轨迹的日志 log: 传给后端的数据参数说明:参数    参数说明pagePath    页面路径intoId    进入小程序的场景值IDoriginId    来源IDuserToken    用户标识upTime    上传信息的时间戳userTrajectoryArr    用户操作轨迹的数组userTrajectoryArr 数组内的对象(用户在小程序里面进行的所有操作都保存在这):参数    参数说明opTime    操作的时间戳opType    操作类型opEvent    操作事件opEventId    操作事件IDopnEventDetail    操作事件详情 opType –  操作类型详细说明:1.页面跳转  2.支付  3.分享小程序  4.跳转小程序 5.页面内点击 6.自定义 7.用户输入  8.拨打客服电话  996.小程序显示   997.小程序隐藏  998.小程序销毁   999.进入小程序调用示例: getApp().getUserTrajectory(1, 'onLoad', 'pages/index_0', '进入小程序首页');//获取用户轨迹数据格式示例: appQuery:{}intoId:1001o开通棉麻风小程序电话:4006-838-530riginId:undefineduserToken:o3XPM4q-4F1IfEYDnBFt2tLZHQ5EupTime:1546499501918userTrajectoryArr:        [ {"opTime":1546499472740,"opType":6,"opEvent":"Require","opEventId":"pages/OrderList/orderHistory/orderHistory_10","opnEventDetail":"订单记录页面请求订单接口","params1":"","params2":"","params3":"开通大牌小程序电话:4006-838-530"},{"opTime"开通壁挂收纳小程序电话:4006-838-530:1546499495706,"opType":999,"opEvent":"AppOnLaunch","opEventId":"app.js_0","opnEventDetail":"小程序启动","params1":"","params2":"","params3":""},{"opTime":1546499495814,"opType":996,"opEvent":"AppOnShow","opEventId":"app.js_1","opnEventDetail":"小程序显示","params1":"","params2":"","params3":""},{"opTime":1546499495876,"opType":1,"opEvent":"onLoad","opEventId":"pages/index_0","opnEventDetail":"进入小程序首页","params1":"","params2":"","params3":""},{"opTime":1546499498787,"opType":1,"opEvent":"navigate","opEventId":"pages/index_3","opnEventDetail":"跳转到订单记录页面","params1":"","params2":"","params3":""},{"opTime":1546499499417,"opType":1,"opEvent":"onLoad","opEventId":"pages/OrderList/orderHistory/orderHistory_0","opnEventDetail":"进入订单记录首页","params1":"","params2":"","params3":""},{"opTime":1546499499454,"opType":6,"opEvent":"Require","opEventId":"pages/OrderList/orderHistory/orderHistory_10","opnEventDetail":"订单记录页面请求订单接口","params1":"","params2":"","params3":""},{"opTime":1546499501042,"opType":6,"opEvent":"Require","opEventId":"pages/OrderList/orderHistory/orderHistory_10","opnEventDetail":"订单记录页面请求订单接口","params1":"","params2":"","params3":""},{"opTime":1546499501478,"opType":6,"opEvent":"Require","opEventId":"pages/OrderList/orderHistory/orderHistory_10","opnEventDetail":"订单记录页面请求订单接口","params1":"","params2":"","params3":""} ]

 承接web前端开发:v:

赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 微信小程序获取用户的操作轨迹日新华区E企盈小程序志
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

模王系统开发

联系我们升级日志

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏