

English
注意
推荐使用 uni统计2.0
Since uni-app 2.2.3, uni statistics are supported. One report, master all data. For business introduction, see https://tongji.dcloud.net.cn
Custom events are an integral feature in statistics. Developers can customize the reporting of statistical data through this API, such as statistical login, registration, and clicking a button, which can be called custom events.
Parameter Description
parameters | type | description |
---|---|---|
eventKey | String | Event name, max length 255 characters |
param | String 、 Object | 事件参数 |
提示
title
, the content title is reported, which cannot be customized by the user. At this time, the data will be displayed in the home page of uni statistics - content statistics and content statistics in the left navigation. Easy to view content page data.uni.login()
, the login event will be executed without parameters. If you need to report data with specific parameters, you need to manually call uni.report('login',{...})
uni.share()
or triggers onShareAppMessage
, the share event will be executed without parameters. If you need to report data with specific parameters, you need to manually call uni.report('share',{...})
uni.requestPayment()
会执行支付事件,不携带参数。如果如需上报携带具体参数的数据,需要手动调用 uni.report('pay_success',{...})
和 uni.report('pay_fail',{...})
Example
// content statistics
// When eventKey is title, param can only be String type
uni.report('title','首页')
// Log in
uni.report('login',{
'name':'uni-app',
'age':'21',
// ...
})
// share
uni.report('share','分享')
// payment successful
uni.report('pay_success','支付成功')
// or
uni.report('pay_success',{
"订单金额":'20元',
"订单名称":'鼠标',
// ...
})
// payment failed
uni.report('pay_fail','支付失败')
// or
uni.report('pay_fail',{
"订单金额":'20元',
"订单名称":'鼠标',
// ...
})
// register
uni.report('register',{
'name':'uni-app',
'age':'21',
// ...
})
// search
uni.report('search','搜索内容')
// or
uni.report('search',{
'内容':'搜索内容'
})
自定义事件上报后:
事件和转换
栏目中,可以看到上报的事件情况。uni statistics --> custom events
column in the uni-admin background, you can see the reported events.uni-ui
中内置了一些数据采集相关的组件,用户使用这些组件,并设置属性 stat:true
,即可在使用相关组件时,自动上报相关自定义数据
In addition to the official uni statistics, if developers also need to call the custom statistics of the applet platform to report data to the background of the applet, they need to use conditional compilation to call their own API on each end.